Changing #define A 1 to .... (this might belong somewhere else)

Posted by Greystar on Fri 09 Aug 2002 09:52 PM — 4 posts, 15,781 views.

USA #0
What I want to do is change the #define structure for Letters.
from
/* RT ASCII conversions -- used so we can have letters in this file */

#define A 1
#define B 2
#define C 4
#define D 8
#define E 16
#define F 32
#define G 64
#define H 128

#define I 256
#define J 512
#define K 1024
#define L 2048
#define M 4096
#define N 8192
#define O 16384
#define P 32768

#define Q 65536
#define R 131072
#define S 262144
#define T 524288
#define U 1048576
#define V 2097152
#define W 4194304
#define X 8388608

#define Y 16777216
#define Z 33554432
#define aa 67108864
#define bb 134217728
#define cc 268435456
#define dd 536870912
#define ee 1073741824

to something like

#define A 01
#define B 02
#define C 03
#define D 04
#define E 05
#define F 06
#define G 07
#define H 08

#define I 09
#define J 0A
#define K 0B
#define L 0C
#define M 0D
#define N 0E
#define O 0F
#define P 10

#define Q 11
#define R 12
#define S 13
#define T 14
#define U 15
#define V 16
#define W 17
#define X 18

#define Y 19
#define Z 1A
#define aa 1B
#define bb 1C
#define cc 1D
#define dd 1E
#define ee 1F

I want to do this to see if I can increase my allowable flags to include

#define ff 20
...
#define zz 34

Obviously I want to change them to hex code.
What I want to know is:

Has anyone done this?
Is it effective to extend the allowable flags though zz?
Does it require a lot of changes to a stock rom code?
Any suggestions are appreciated, flames to a minimum please.

Thanks
Australia Forum Administrator #1
Your idea won't work as presented, sorry.

The problem is that each flag must be a unique 'bit' in the resulting word in memory.

For example, your idea of defining C as 3, means if you used C it would also match A and B.

Look at it from the bit pattern point of view and you'll see what I mean:

A 0001
B 0010
C 0011

In the original system each new flag is a power of 2, (2, 4, 8, 16 and so on). So the original system looks like this:

A 0001
B 0010
C 0100
D 1000

So you see that the bits don't overlap. Thus, you can have flags A and B set (which will be 0011). In your system you would have no way of distinguishing between A and B set (0011) and C being set (0011).

The original system squeezes as many flags as it can into a 32-bit word (actually there seem to be 31 of them, A-Z plus aa-ee, which probably is because they didn't want to use the 'sign' bit which is the 32nd. bit).

Your only option is to use another field (ie. another 32 bits).
Australia Forum Administrator #2
Writing them in hex does't change the underlying problem, and in any case my example shows that the system falls down even in the case of 1 to 3, which is the same in hex and decimal.

BTW - if you wanted to write in hex the syntax is:

#define M 0x0D

(Your system would compile OK, it would just behave *very* strangely when you tried to use the flags).
USA #3
Thanks! I think I got what I want now though. I got it so it works with 64 bits... still testing though.