Well, before you start worrying about that stuff, I would think you need to get a solid format going for how you represent your molecules in memory. I would say that your data structures for each of your atoms should look like this.
[Atomic number][lone pairs][charge][flags xx112234][bonded id 1][bonded id 2][bonded id 3][bonded id 4][bonded id 5][bonded id 6][display x][display y]
Where: - atomic number = atomic number - lone pairs = number of lone pairs - charge = formal charge - flags = bond type 0 = single bond, 1 = double bond, 2 = triple bond, 3 = ionic - bonded id # = the array position of the other atom it is bonded to - display x/y = where it is displayed on the full buffer
So with this system, you have the 10 byte atom structures lined up in memory. Each one would have an ID based on where it is in memory as well as the atoms it is bonded to. The goal would then be to parse what the user typed and turn it into one of these structures. If you start to get triple bonds, you may have to switch some of the bond id's around as you add them, but that is fine.
Using this system, you should be able to represent any kind of atom I can think of, even complex organic molecules.
Then, onto your questions: 1. This one is easy, assuming you don't start getting really space filling molecules (2,2 - dimethylpropane), the angle calculation is as simple as taking 360 divided by the number of atoms and lone pairs bonded to the atom. So, if it is bonded to 2 atoms and has one lone pair, 360/3 = 120. Then you'll just have to make a sine and cosine LUT to figure out how to draw your lines. (The LUT only needs 360, 180, 120, 90, 72, and 60)
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.
Weird stuff happens sometimes. Archive everything that does not appear to be corrupted (size looks correct) and clear ram. There's a 99% chance this will fix your problem. If it doesn't, then we get to have some more fun.
If xeda will give me an entry point, I'd be glad to do it.
However, in the grand scheme of things, I'd like to see Grammer get a little bigger before I add support for it. Like I said, I'm pretty low on space and adding in options like this takes a minimum of 100 bytes.
One option that I do like would be to somehow use the "Run on zStart" option to add in a hook to make it work. I don't see that being very difficult.
This isn't exactly a funny quote, but it is definitely my favorite moment from IRC.
Quote
[18:13:58] <+BrandonW> I'm not sure what everyone else is doing, but I'm working on Pocket stuff. [18:14:40] <+BrandonW> I'm still ironing out some kinks, but I did complete the conversion and confirm the exploit works. [18:14:57] <+OmnomIRC> (O)<thepenguin77> oh, I got it to work on my 84+SE [18:15:09] <@calcdude> penguin, you did it too? [18:15:27] <+OmnomIRC> (O)<thepenguin77> lol, yep, I had to join in the fun [18:15:48] <+BrandonW> Then I'm sure you know why it needs to be protected. [18:16:01] <+OmnomIRC> (O)<thepenguin77> definitely, it is golden [18:16:11] <+BrandonW> Good enough for me. [18:17:03] <+OmnomIRC> (O)<thepenguin77> the best part, is that the only side effect is the ti-connect crashes [18:17:11] <+OmnomIRC> (O)<thepenguin77> nothing else [18:17:26] <+BrandonW> It doesn't crash for me. [18:17:39] <+OmnomIRC> (O)<thepenguin77> oh, well, it got stuck because I didn't finish [18:18:02] <+BrandonW> I'm not sure why it would since it acks before all that new crap. [18:18:19] <+OmnomIRC> (O)<thepenguin77> well, there is one final ack right before the new bcall [18:18:36] <+BrandonW> Right, before. [18:18:47] <+OmnomIRC> (O)<thepenguin77> omg, we are using different exploits [18:19:18] <+BrandonW> I win! :) [18:19:23] <+BrandonW> No crash for me. [18:19:26] <+OmnomIRC> (O)<thepenguin77> hold on, I'm getting on IRC [18:19:51] * thepengwn ([email protected]) has joined #omnimaga [18:19:51] * Netbot45 sets mode: +v thepengwn [18:19:57] <+OmnomIRC> (O)<thepenguin77> start a pm with me, I don't know how to do it
... 11 minutes later...
[18:31:24] <+OmnomIRC> (O)<thepenguin77> wow, if anyone just saw what happened, brandonW and I come up with different ways to beat boot code 1.03
Visual Studio's been working great for me for over 2 years now. Granted I've never tried anything else, but setting up your environment is as simple as installing the program.
One of the things I love about it is that it red underlines stuff that it knows is going to cause a compiler error, that definitely improves your C++ skills
I'm very glad to hear that, because I never actually tested it
I don't have the means to make an axe program large enough to test it so I just figured that since it put the ports in the right states, it should work. And I guess it does.
I was looking through starfox when I saw some code that used DJNZ in an unconventional way, this made me think about how useful it is, so here are some things I just thought of.
On this first one, you're going to say, "well duh," but I bet you don't do it.
One benefit of this is that you don't destroy A. Now before you start complaining about that 1 t-state, just remember, if you manage to put your result into B rather than A, this routine becomes 3 t-states faster.
Here is another common code structure that I run into a lot:
;###################################### ;plot a byte ;a = byte ;b = inverse 1 = yes, 0 = no ;de = xy
plotAByte: ldc, d ldd, 0 ldh, d ldl, e addhl, de addhl, de addhl, hl addhl, hl srlc srlc srlc lde, c addhl, de ldde, plotSScreen addhl, de
djnzinversing
or(hl) ld(hl), a ret
inversing: cpl and(hl) ld(hl), a ret
Also, while it's not a new idea today, I have used DJNZ in weird ways before, I typically do it when unpacking bytes from storage. This routine is from zStart and pulls a name out of storage from 6 bytes to 8 bytes. I use B as a bit counter.
I was going to port my example over to C++, but I realized that if you are writing it on the computer, my technique won't work. I specially optimized mine for the calculator and it relies on the fact that you are storing your picture in monochrome. Most likely you'll have 24-bit pixels so for mine to work correctly would take a lot of work.
I know one easy way to do it, though I'm not sure how good it would look. I really have no way to describe it other than in steps:
1. First, you need a counter, I will make it 8-bit and call it _C, the counter starts at 00. 2. Clear your buffer
OuterLoop: 3. Set a pointer to the beginning of the picture buffer
InnerLoop: 4. Take a random 8-bit number, AND it with _C, then OR it with the current data in the picture buffer and store it 5. Rotate _C by one bit (left or right doesn't matter, just keep it consistent) 6. Increase to the next byte in the picture buffer 7. Goto InnerLoop until you are at the end of the buffer
8. Increase _C by 1 (the real _C, not whatever kind of rotated crap you ended up with after the inner loop) 9. Goto OuterLoop as long as _C is not equal to 256 (0)
10. Goto OuterLoop a few more times with _C = 255 just to make sure any stragglers get filled in
That aught to do it. The only thing that will break it is if your random routine isn't truely random. You might also get interesting results if you randomly rotated _C rather than just rotating it by 1.
I think my favorite part of chemistry is doing it at my house
But, I'm in my third year of chemistry (Regular, AP Chemistry, now Organic Chemistry) and I'm hoping to go into chemical engineering when I go to college. You could say that I basically am chemistry.
For those who haven't figured out where the name came from, I knew I had to use the word full, as in "full Ram", but I had to make it cool. So then I decided on Fullrene, those cool carbon creations, only to find out that it's spelled Fullerene.
I believe that this axiom is ready to go. It appears to work on every emulator I've tested it on, so it should be good.
A few notes on usage:
Syntax: Fcdf() or Fcdf()r (preferably at the start of the program)
The version without r will work on all calculators and is 163 bytes, period.
The version with the r won't work on the 83+BE, but is only 78 bytes.
This axiom sets up a wrapper around your entire program so that it can disable this feature when you quit. This means that you should either try to end your program by using Return or running off the end of the program. (Returnr still works, but it's bad practice to leave the calculator in this unlocked state.)
This routine disables interrupts
You should already know how Axioms work, but if you don't, send this appvar to your calculator and put it in flash. To include the axiom in your Axe program, add the line:
lda, 1 out(05), a rrca ldi, a;$80 deca out(06), a;$7F
ina, (02) bit5, a
lda, $C3;jp REP_NEXT ldhl, returnPointz
jrz, _83PlusSE _84Plus: ld($80C8), a ld($80C9), hl jp$4529
_83PlusSE: pushaf;sp-2 ld($80FE), a ld($80FF), hl jp$4276
returnPointz: saveSPequ$+1 ldsp, 0000 xora out(05), a popaf out(06), a lda, $10 jrnc, wasUndoing xora wasUndoing: out($25), a bcall(_flashWriteDisable) ret
ld(hl), b;b is zero popaf lda, $1F jrc, notLocking ld(hl), a;should be $0F notLocking: dechl out(06), a out(05), a;should be 7 call$46D8;hack, works on 1.00 and 1.01 pushaf
regularUnlock: popaf lda, $10 jrnc, wasUndoingz xora wasUndoingz: out($25), a finishUp: popaf out(06), a bcall(_flashWriteDisable) ret
If you're in Chrome, it's probably best to just quote this post.