I had an old program that I made in TI-Basic. I have wanted to convert it into z80 for a while. It was a Lewis Structures drawing program. It several shortcomings: (1) it could not handle drawing off-screen, and (2) It could only handle formulas with one central atom, and the others around it. (NH4, for instance).

I want to redo this. In z80. So, I'm asking the following questions:

1. How do I calculate angle degrees in z80? When drawing Lewis Structures, spare electrons must be accounted for by leaving one space. For instance, in a water molecule, you know that it is a bent molecule. Because of the electrons left unbonded on the hydrogen, the oxygen molecules are pushed to the opposite side, at 90 degree angles to each other. Understand what I'm asking? Or maybe someone who knows more about this can explain better?

2. How do I make the program able to scroll to the left or right of the display in order to show offscreen parts? Would the DCS GUI features be best for this?


Any help I could get would be great. I'd be willing to co-author the project with someone who knows how draw Lewis Structures , who could handle the technicalities of calculating and drawing.
What do you mean by calculating angle degrees, exactly? Turning radians into degrees? Turning degrees into X and Y? If you mean the latter, I have some fixed-point trigonometric routines from Obliterate that I could contribute to the project. For the second question, I definitely think the DCS GUI would be the best. Just construct the whole thing in an offscreen buffer, then use a scrollbar with callbacks to select which part is shown at a time.
ACagliano wrote:
When drawing Lewis Structures, spare electrons must be accounted for by leaving one space. For instance, in a water molecule, you know that it is a bent molecule. Because of the electrons left unbonded on the hydrogen, the oxygen molecules are pushed to the opposite side, at 90 degree angles to each other. Understand what I'm asking? Or maybe someone who knows more about this can explain better?


I think I know what you're thinking of, but I have no Idea how to do it.
KermMartian wrote:
What do you mean by calculating angle degrees, exactly? Turning radians into degrees? Turning degrees into X and Y? If you mean the latter, I have some fixed-point trigonometric routines from Obliterate that I could contribute to the project. For the second question, I definitely think the DCS GUI would be the best. Just construct the whole thing in an offscreen buffer, then use a scrollbar with callbacks to select which part is shown at a time.


By calculating degrees, I mean figuring out the x and y position to place a molecule, with respect to the central molecule.

For the second, I think I will use the DCS GUI, although I may be posting more questions as I get to that part.
If you have the coordinate for the central atom, you would use the unit circle to find points around it with an angle. Once you have routines for sine and cosine, it shouldn't be too hard.
souvik1997 wrote:
If you have the coordinate for the central atom, you would use the unit circle to find points around it with an angle. Once you have routines for sine and cosine, it shouldn't be too hard.
Indeed, which is what I have and could give him. They're 16-bit fixed-point routines in 8.8 format, which means the first 8 bits is the integer part, and the section 8 bits is the decimal part. I wrote my routines and lookup tables in 4-degree increments, because that's all the precision I needed for the z80 version of Obliterate. It would be easy to modify the tables for more (or less) precision as needed.
Thanks Kerm. To be honest, the only angles I really need to be able to draw are multiples of 360/8 (I think), since a valence orbital can only hold a maximum of eight electrons.

Now, for any of you chemistry people here, how do you determine which atoms form the central atoms of the molecule or chain and which go around the central atoms?


Oh, I need help with one routine. I need to parse a sector of memory from Label "ElementDataTable" forward. I need to look for a one or two byte search string. But the issue is this... take C and Co for example. If I search C, the element database lists it as "C_", where _ is a blank space. I can't have it return every element starting with C. lol.
ACagliano wrote:
Thanks Kerm. To be honest, the only angles I really need to be able to draw are multiples of 360/8 (I think), since a valence orbital can only hold a maximum of eight electrons.

Just to throw in my two cents, I like to use a 256-entry sine/cosine table using what I call "byte degrees". Instead of radians or degrees, there are 256 byte degrees in a complete circle. Each entry is one byte containing the sine of the angle, scaled by 127. So sin(64)=127, sin(128)=0, sin(192)=-127, and so on. It's fairly easy to work with since everything fits in 8 bits (ie, a single register), and it has enough precision for decent graphics on a low-resolution calculator screen.

Quote:
Oh, I need help with one routine. I need to parse a sector of memory from Label "ElementDataTable" forward. I need to look for a one or two byte search string. But the issue is this... take C and Co for example. If I search C, the element database lists it as "C_", where _ is a blank space. I can't have it return every element starting with C. 0x5.

You're a little light on details on how the table is laid out, but if you search for a one-letter element name, you could add a space to the end of the search term and treat it like a two-letter name, and it will have only one match (the "C_" element in your example).

If you need more help with how to do the string search, we'll need to know more about the memory layout. Are the element symbols stored contiguously, such as "H_HeLiBeB_C_N_O_F_..."?
I no longer need help with the above...I can handle it. But, i do need to ask... DCS_GUI-wise. To render the molecule on the screen and have it scrollable, what GUI functions would I use? I know the horiz and vert scrollbars, but what sprite function would I use?

Edit: Wait, I can't even do that, because the molecule is rendered on the basis of the molecule data. The molecule data has this format:

byte 0 [Atomic number]
byte 1 [# of lone pairs]
byte 2 [charge]
byte 3 [flags xx112234]
byte 4 [bonded id 1]
byte 5 [bonded id 2]
byte 6 [bonded id 3]
byte 7 [bonded id 4]
byte 8 [bonded id 5]
byte 9 [bonded id 6]
byte 10 [display x]
byte 11 [display y]

Where bytes 10 and 11 control the position of that atom on the large buffer. And bytes 4-9 are pointers to the structures of the atoms bonded to that atom.
Would you mind helping me understand where the question is in all that? Smile I see you asked about a sprite routine, but then you seem to have gone on to detail the structure of your database.
KermMartian wrote:
Would you mind helping me understand where the question is in all that? Smile I see you asked about a sprite routine, but then you seem to have gone on to detail the structure of your database.


Oh, fail. Basically, my question is...taking into account the fact that the data is formatted as such, not as an actually buffer, it would be impractical to use the DCS drawing routines, am I right?
ACagliano wrote:
KermMartian wrote:
Would you mind helping me understand where the question is in all that? Smile I see you asked about a sprite routine, but then you seem to have gone on to detail the structure of your database.


Oh, fail. Basically, my question is...taking into account the fact that the data is formatted as such, not as an actually buffer, it would be impractical to use the DCS drawing routines, am I right?
I don't agree with you there. It's quite easy to render arbitrary graphics into a temporary memory buffer somewhere, then push that into the GUIStack as a sprite. I do that trick in many programs, including Document DE and Sandpaper.
ACagliano wrote:
the oxygen molecules are pushed to the opposite side, at 90 degree angles to each other.

Sure about that? My BINAS (Book full of tables used alot in the Netherlands) says "bondingsangle" between H-O-H is 104.5º.
arriopolis wrote:
ACagliano wrote:
the oxygen molecules are pushed to the opposite side, at 90 degree angles to each other.

Sure about that? My BINAS (Book full of tables used alot in the Netherlands) says "bondingsangle" between H-O-H is 104.5º.

I know. I was just giving an example.

Can anyone here tell me, what is used to determine what molecules go in the central atom/central chain, given only a formula? And, I know about VESPR, but this program is all inclusive...I want it to work regardless of HOW you input the formula. There has to be something. Valence electron count. Electronegativity.
The nice thing about molecules is that they have multiple structural formulas for one moleculair formula. Those different molecules are called "isomeres" (at least they do in the Netherlands). For example, if you have "butaan", C4H10, that comes in:

Code:
  H H H H         H H H
H-C-C-C-C-H and H-C-C-C-H
  H H H H         H | H
                  H-C-H
                    H

This means that there is really no way you can draw a structural formula based on the moleculair formula.
Edit: this is what I thought you wanted to make, correct me if I'm wrong.Smile
(We call that "Butane" Wink). And indeed, the chemical formula doesn't tell you much about the structure of a particular molecule, unfortunately.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement