This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - ACagliano
Pages: 1 ... 17 18 [19] 20 21 ... 62
271
« on: October 31, 2011, 08:59:39 am »
2. Scrolling is a bit harder, any way you do it it's going to be messy. I have two approaches, the oversized buffer method, and the clipping method.
- Oversized buffer: For this, you'll want to allocate a big buffer, 150x150 pixels should be fine. Then, you'll have to make your own drawing methods to draw to this buffer. You really only have to copy over a line drawer and a vPutS, which isn't really that tough. After that, you simply draw you whole molecule to the buffer and only display the 96x64 region that is currently showing.
- Clipping method: This method might be harder, but it uses fewer resources. You will probably be able to use the system vPutS for this but you'll need a special line routine that automatically clips itself to the edges of the screen. (badja made one). From here, you also need to define how far the screen has scrolled from the top left corner of the true screen. The final step is just to take the coordinates of something on the screen, subtract from it how much the screen has shifted, and draw the atom to the resulting position on the screen. You'll just have to watch out to make sure that you don't accidentally try to vPutS something off the screen.
I would highly recommend not going with the virtual buffer method. As you mentioned, it's messy. It's also rather inefficient for long carbon/Silicon chains where you have large 2d plots, but relatively few molecules. I'd instead recommend a more "vector"-ish approach where the coordinates of the nuclear centers are represented in a virtual 3d space as a table of coordinates and bond relations. When you need to display them, you define a 2d buffer that will be directly translated to the screen and just project the points from that 3d space into the buffer along with the bonds. A bit more complex, perhaps, but it allows "infinite resolution" of arbitrarily large molecules (within reason of course) and uses a less memory for molecules with low nuclear density since all you're storing is an extra coordinate over the 2d buffer method.
As for generating the structures themselves from the formulas, I'll be blunt. It's basically impossible to do at any significant level of accuracy, since the structure of a molecule depends on a lot more than just an enumeration of the atoms in it. For example, it often depends on the prior history of its constituent atoms. A good demonstration of this is Barrelene, a molecule with the formula C8H8. This molecular formula is also shared by Cubane and Styrene, among a few others. These isomers are all [somewhat] stable in their radically different configurations and determining which one the user means is nigh impossible. A structural formula like SMILES is much less ambiguous, pretty widely available for most molecules, and essentially eliminates the near impossible problem of predicting molecular structure.
Hmmm. I think I know what you are talking about, but I will not be able to do a 3d rendering on my own. As for the structures, I'm just interested in a general drawing, not with prior conditions and stuff. Just the simple textbook way we learned to draw Lewis Structures. What does SMILES mean again?
272
« on: October 30, 2011, 11:49:42 am »
ok. I'll see what I can do. Question. For "atomic number", can't I just use the number of valence electrons? I think that, when it comes to drawing Lewis Structures, only the valance orbital is what affects bonding.
Well, yeah, you could do that, but then you wouldn't know what letter to display . It depends how far you want this program to go, but you might have to look farther than valence electrons if you are going to handle expanded octets.
I may need help with rendering the final object to the screen.
Ok
Also, how do you determine what molecules make up the main chain, and what molecules go around the main chain?
That is where the real challenge comes in. For inorganic stuff, you might almost need to have a database of polyatomic ions. For your purposes, you probably shouldn't end up having more than 50. If you don't want to do that You could also try to determine the structure of the polyatomic ion by comparing the number of valance electrons of each atom along with how many of each atom is present. Typically, the element with the most atoms will be the outer atoms with oxygen almost always being an outside atom. (I can think of a few weird ones, CN-, SCN-, and OCl-. Also, stuff like NO3- has a double bond in it.)
For organic materials, once you figure out a system, it shouldn't really be that hard. Just try to determine what structures are side chains and what are main chains and you should be ok. If you really love chemistry, you could try to parse IUPAC names, but that would be tough.
I can do the chart of polyatomics, so that first, the program compares the input with the polyatomics chart. Secondly, I found two rules to use...(1) the atoms with the highest number of valence electrons are usually the central atoms, and (2) the atoms that are the least electronegative are usually the central atoms. I'm currently looking for a computer algorithm to determine the central atoms, but I doubt I'll find one.
273
« on: October 29, 2011, 10:54:02 am »
ok. I'll see what I can do. Question. For "atomic number", can't I just use the number of valence electrons? I think that, when it comes to drawing Lewis Structures, only the valance orbital is what affects bonding.
I may need help with rendering the final object to the screen.
Also, how do you determine what molecules make up the main chain, and what molecules go around the main chain?
274
« on: October 28, 2011, 09:41:30 pm »
Also posted on cemetech...
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. Such that it can not only handle such formulas as HH4 and H2O but more complex ones as well, and shows single, double, and triple bonds. 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.
275
« on: October 11, 2011, 09:33:29 pm »
So if you want to delay for approximately 'a' seconds you can try this:
ld b,107 halt djnz $-1 dec a jr nz,$-6 ret
Does this help?
Remember to have interrupts enabled. 
Thank you mucho. I don't actually disable them to begin with...lol.
276
« on: October 11, 2011, 08:25:38 pm »
So if you want to delay for approximately 'a' seconds you can try this:
ld b,107 halt djnz $-1 dec a jr nz,$-6 ret
Does this help?
What does $-6 mean? $-1?
277
« on: October 11, 2011, 08:21:42 pm »
Ok, now, all I have to do is figure out...right now 'a' is in milliseconds. My 'a' is in seconds.
278
« on: October 11, 2011, 07:20:50 pm »
Multiply hl by 1000 to turn it into milliseconds. If you don't need all of the precision, leftshifting hl by 10 is approximately the same.
Can I use a for this, rather than hl? And what routines can I use to draw a line between two pixel coords?
279
« on: October 11, 2011, 07:14:50 pm »
;hl = milliseconds of delay
milliDelay: ld b, 174 ;7 innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257
dec hl ;6 ld a, h ;4 or l ;4 jr nz, milliDelay ;13 ret ;15,515 What would I do if hl is in seconds, rather than milliseconds? And, actually, my code holds the number of seconds to delay in 'a'.
280
« on: October 10, 2011, 10:03:21 pm »
Yeah. I think I can handle that. How many 'nop' or 'halt' cycles would equal 1 second, in fast mode?
For nops, you need whole heck of a lot. Each nop takes 4 t-states. And you figure the median calculator is running at 15,500,000 t-states per second so... 3.7 million nops.
If you want to use instructions to slow down your program, here's a routine you can use:
;hl = milliseconds of delay
milliDelay: ld b, 174 ;7 innerLoop: ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 ex (sp), hl ;19*174 ;3306 djnz innerLoop ;13*173+8 ;2257
dec hl ;6 ld a, h ;4 or l ;4 jr nz, milliDelay ;13 ret ;15,515
Halts work entirely different though. Halts wait for an interrupt and the interrupts run at a constant speed. That speed is 118 Hz on an 83+ and 107.79 Hz on everything else. But since you said you're running in fast mode, clearly you are not on an 83+ so you would need 108 halts to wait for one second.
(I said "median" calculator up above because calculators run anywhere from 14.5 MHz to 17.0 MHz in fast mode)
Well, this may be the delay I utilize. Let me clarify...by "fast mode" I mean that I have opened the program with this... in a,($2E) ;initialize faster processing push af ld a,0 out ($2E),a call Start ;jump to main program. the main program will return here when 'ret' is called pop af out ($2E),a ret
281
« on: October 10, 2011, 01:30:43 pm »
1. I know my house might get bombed for this, but honestly, the only way I can see to do this would be to check out how Axe does it. Axe draws perfect circles very quickly and if I needed a circle routine, I would just copy axe's. Ok. Will do. 2. This one has actually been done for you, bcall(_DrawRectBorderClear) draws a rectangle with a white inner section. (Page 142 if your browser doesn't redirect you)
Awesome. Thanks. 3. If you mean just draw text, then bcall(_vPutS) is your routine. But, if you mean draw text within a certain boundary area, bcall(_SFont_Len) will tell you how long an individual letter is. From there, you can draw the letters 1 by 1 with bcall(_vPutMap) and start a new line whenever you run out of space. (bcall(_SFont_Len) is on page 47 of that pdf I linked above)
Yeah, I'll be drawing text of the small font within a boundary area. 4. There are so many sprite rendering routines, there's no need to make a new one. Here is a page for 8-bit wide sprites and here is a page for 16-bit wide sprites. However, if you want just a single routine to do all of your sprites no matter how big they are, this is your routine. Of course, picking one of the smaller ones would be faster than this though.
I need one routine to draw sprites of different sizes. Thanks. As for the delays, your best bet is to make a single delay routine and call it. In all honesty this routine right here is probably all you need:
Delay: dec hl ld a, h or l jr nz, delay ret
Yeah. I think I can handle that. How many 'nop' or 'halt' cycles would equal 1 second, in fast mode?
282
« on: October 10, 2011, 10:14:06 am »
I need a couple asm routines. They are for a program I am working on. They are as follows. The data the routine reads will be pushed onto the stack. Assuming you pop into hl:
1. Render a circle onto the screen hl = time to wait, after rendering element, before moving on hl + 1 = circle center x coord hl + 2 = circle center y coord hl + 3 = radius
2. Render a white rectangle with black border onto screen hl = time to wait, after rendering element, before moving on hl + 1 = x of upper left corner hl + 2 = y of upper left corner hl + 3 = width hl + 4 = height
3. Render text onto the screen hl = time to wait... hl + 1 = x to start display hl + 2 = y to start display hl + 3 = width of text display (in chars) hl + 4 = zero t'ded string
4. Render sprite onto screen hl = time to wait... hl + 1 = x to start hl + 2 = y to start hl + 3 = width hl + 4 = height hl + 5 = sprite data
Any help would be great.
283
« on: October 06, 2011, 07:06:46 pm »
If this app becomes two or more pages long (which I reckon it will), is there anything I will need to do, codewise?
284
« on: October 06, 2011, 03:12:59 pm »
Ok, I PM'd you both. You guys can split the sprites. Monochrome* 8x8.
285
« on: October 05, 2011, 07:26:22 pm »
I am looking for someone to take on the task of doing my Zelda sprites. I have alot of other work to do, codewise, so I would be grateful to anyone who would be so kind as to contribute in this area. You will, of course, receive credits for the sprite graphics. Anyone willing to help?
Pages: 1 ... 17 18 [19] 20 21 ... 62
|