Show Posts

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 - thepenguin77

Pages: 1 ... 33 34 [35] 36 37 ... 108
511
ASM / Re: Angle Calculation Help
« on: October 28, 2011, 11:20:41 pm »
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.

512
General Calculator Help / Re: My calculator will not turn off
« on: October 28, 2011, 10:50:29 pm »
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. ;D

(Clear ram: [2nd][+ ][7][1][2])

513
TI Z80 / Re: zStart - an app that runs on ram clears
« on: October 24, 2011, 06:17:00 pm »
That looks good to me. I don't even need to 4088h routine. But, the more the merrier I guess.

514
TI Z80 / Re: Wormy!
« on: October 24, 2011, 06:13:47 pm »
I saw the title wormy and I got scared. (BraondonW also released a program called wormy and it changes your TI-84+SE into a TI-84+BE)

515
TI Z80 / Re: zStart - an app that runs on ram clears
« on: October 24, 2011, 02:57:38 pm »
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.

516
Humour and Jokes / Re: Funny #omnimaga quotes (NSFW)
« on: October 23, 2011, 10:39:45 pm »
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


It's just one of those "WTF!?" moments.

517
Computer Programming / Re: Help with C++
« on: October 22, 2011, 01:48:12 pm »
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 ;D

518
Computer Programming / Re: Passing a pointer to an array of an array
« on: October 22, 2011, 11:20:04 am »
That might work, but why not save all the hassle and do this?

Code: [Select]
int my_array[26][24] = {0};

call_function(my_array);

////////////////////////////////

void call_function(int array[26][24])
{
for (int iii = 0; iii<26; iii++)
{
for (int jjj = 0; jjj<24; jjj++)
{
array[iii][jjj] = iii*jjj;
}
}
}

When you just type the name of an array, like "my_array," that actually is the pointer to the array. You only dereference it when you start to use [].

Also, I would suggest that you use a 1 dimensional array. Two dimensional arrays are just handled like 1 dimensional arrays in memory anyways.

519
TI Z80 / Re: Fullrene
« on: October 21, 2011, 06:18:16 pm »
I'm very glad to hear that, because I never actually tested it ;D

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.

520
ASM / Mad DJNZ Hacks
« on: October 21, 2011, 05:53:11 pm »
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.

Let's say you want to see if A==1:
Code: [Select]
dec a
jr nz, AWasnt1

You could replace it with this for only 1 extra t-state:
Code: [Select]
ld b, a
djnz AWasnt1

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:
Code: [Select]
ld a, (hl)
dec a
jr nz, not1
...
jr final
not1:
dec a
jr nz, not2
...
jr final
not2:
dec a
jr nz, not3
...
jr final
not3:
dec a
jr nz, not4
...
jr final
not4:
...
final:

Why not replace it with this, which is both faster and smaller (you don't need the jumps if you can leave b at 0):
Code: [Select]
ld b, (hl)
djnz not1
...
not1:
djnz not2
...
not2:
djnz not3
...
not3:
djnz not4
...
not4:
djnz not5
...
not5:

final:


Finally, this one is a bit more of a stretch, but you can use B as a flag byte, take for instance this byte plotter:
Code: [Select]
;######################################
;plot a byte
;a = byte
;b = inverse 1 = yes, 0 = no
;de = xy

plotAByte:
ld c, d
ld d, 0
ld h, d
ld l, e
add hl, de
add hl, de
add hl, hl
add hl, hl
srl c
srl c
srl c
ld e, c
add hl, de
ld de, plotSScreen
add hl, de

djnz inversing

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.

Code: [Select]
pop hl
ld ix, op1+1
ld bc, 8*256+6
ld d, 8
xor a
unpackNameLoop:
rr (hl)
rra
djnz notNextUnpackByte
inc hl
ld b, 8
notNextUnpackByte:
dec c
jr nz, unpackNameLoop
ld c, 6
rra
rra
ld (ix), a
inc ix
xor a
dec d
jr nz, unpackNameLoop

521
TI Z80 / Re: Fullrene
« on: October 20, 2011, 02:52:15 pm »
That is by far the greatest thing I have learned all week. I didn't realize that you could edit webpages on the fly. I'll have fun with this ;D

(Yes, I realize it's only on my computer)

522
General Calculator Help / Re: Random Space Filling
« on: October 19, 2011, 11:18:23 pm »
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'd go with the mixing up idea.

523
General Calculator Help / Re: Random Space Filling
« on: October 19, 2011, 10:04:52 pm »
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. ;D You might also get interesting results if you randomly rotated _C rather than just rotating it by 1.

Edit:
    The second AND is an OR

524
Math and Science / Re: Chemistry
« on: October 19, 2011, 05:40:29 pm »
I think my favorite part of chemistry is doing it at my house :P

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.

525
TI Z80 / Re: Fullrene
« on: October 18, 2011, 05:50:16 pm »
Most Recent Version Here

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:
Code: [Select]
:AsmComp(FULLRENE)
   or
:#Axiom(FULLRENE)      (Axe hooks)

Then, include this line preferably at the top of your program.
Code: [Select]
:Fcdf()        (all calculators)
   or
:Fcdf()r        (non-83+BE calculators)

If you can't find Fcdf(, it's in [2nd] [Vars] [9 or 0] ;)

Also, if today is your lucky day, here is the code to optimize: (I'd be happy with even a single byte)
Spoiler For Spoiler:
R Version
Code: [Select]

scf
REP_NEXT
call unlockflash
REP_NEXT
call rVersionEnd
or a

unlockFlash:
in a, (06)
push af
REP_NEXT
ld (saveSP), sp
ld sp, $82A9+$4000

ld a, 1
out (05), a
rrca
ld i, a ;$80
dec a
out (06), a ;$7F

in a, (02)
bit 5, a

ld a, $C3 ;jp
REP_NEXT
ld hl, returnPointz

jr z, _83PlusSE


_84Plus:
ld ($80C8), a
ld ($80C9), hl
jp $4529


_83PlusSE:
push af ;sp-2
ld ($80FE), a
ld ($80FF), hl
jp $4276



returnPointz:
saveSP equ $+1
ld sp, 0000
xor a
out (05), a
pop af
out (06), a

ld a, $10
jr nc, wasUndoing
xor a
wasUndoing:
out ($25), a
bcall(_flashWriteDisable)
ret

rVersionEnd:
Non R Version
Code: [Select]
scf
REP_NEXT
call doIt
REP_NEXT
call allVersionEnd
or a

doIt:
        in a,(6)
        push af
push af
;UnlockFlash:
;Unlocks Flash protection.
;Destroys: appBackUpScreen
;          pagedCount
;          pagedGetPtr
;          arcInfo
;          iMathPtr5
;          pagedBuf
;          ramCode

        ld a,7Bh
        call translatePage
        out (6),a

ld hl, ($5092)
ld a, ($5094)

        call translatePage
        out (6),a
        ld a,0CCh
ld b, a
        cpir
        ld e,(hl)
        inc hl
        ld d,(hl)
ld (iMathPtr5), sp
        push de
;       pop ix

ld a, $C3
ld ($9898), a
REP_NEXT
ld hl, returnPoint
ld ($9899), hl

        ld hl,pagedBuf
        ld (hl),98h
        ld de,pagedBuf+1
        ld bc,49 ;so lucky VV
push bc
        ldir
        ld hl,(iMathPtr5)
push hl
        ld de,9A00h
        ld bc,50

ld a, c

        ldir  
        pop de
        ld hl,-14
        add hl,de
        ld (iMathPtr5),hl
pop iy ;that was convenient
;       ld iy,0056h-25h
;       ld a,50 ;covered
        ld (pagedCount),a
        ld a,8
        ld (arcInfo),a
;       jp (ix)
translatePage:
       bcall(_NZIf83Plus)
        ret z
        and 1Fh
        ret
returnPoint:
        ld iy,flags
ld hl,(iMathPtr5)
        ld de,14
        add hl,de
        ld sp,hl
        ex de,hl
        ld hl,9A00h
        ld bc,48
        ldir

in a, (02)
rlca
jr c, regularUnlock

ld (hl), b ;b is zero
pop af
ld a, $1F
jr c, notLocking
ld (hl), a ;should be $0F
notLocking:
dec hl
out (06), a
out (05), a ;should be 7
call $46D8 ;hack, works on 1.00 and 1.01

push af

regularUnlock:
pop af
ld a, $10
jr nc, wasUndoingz
xor a
wasUndoingz:
out ($25), a
finishUp:
pop af
out (06), a
bcall(_flashWriteDisable)
ret

If you're in Chrome, it's probably best to just quote this post.

Pages: 1 ... 33 34 [35] 36 37 ... 108