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 ... 58 59 [60] 61 62 ... 108
886
ASM / Re: please help me with fixed-point math
« on: May 22, 2011, 07:23:42 pm »
Ok, yes, what you are saying is true. The problem is that when you are working with 16 bit numbers, you are treating them as two sets of 8 bit numbers rather than a set of 16 bit numbers. To demonstrate, I have to go back in math a long time:

Let's say that you need to add two numbers together. Lets say 23 and 69.
Code: [Select]
     2 3
    +6 9
--------

Adding the ones, you get this:
Code: [Select]
     2 3
    +6 9
--------
      12

But that won't do, so we have to carry the one:
Code: [Select]
     1
     2 3
    +6 9
--------
       2

And we finally end up with:
Code: [Select]
     1
     2 3
    +6 9
--------
     9 2

Now, to put this into bytes: Let's say that you need to add two 16 bit numbers, $5678 and $BCDF. $5678 is two bytes of $56 and $78. So if we convert that to two decimal bytes, we get $5678 = 86 120 and $BCDF = 188 233.
Code: [Select]
    86 120
  +188 233
----------

We add the first bytes together, just like you do:
Code: [Select]
    86 120
  +188 233
----------
       353

353 is not going to fit into one byte. So we have to convert that to 97 and carry a 1 to the next byte:
Code: [Select]
     1
    86 120
  +188 233
----------
        97
So now we add the second bytes:
Code: [Select]
     1
    86 120
  +188 233
----------
   275  97
But what's that, another overflow:
Code: [Select]
     1
    86 120
  +188 233
----------
 1  19  97

So we can see here that the final result is actually 3 bytes. What you have to remember is that the bytes are dependent of each other when you are doing math operations on them. The exact same thing I showed here happens in subtraction. And when you multiply or divide two bytes, the results are really wrong because when multiplying two bytes, it looks like this:

$5678 * $BCDF = ($5600 + $78) * ($BC00 + $DF) = ($5600 * $BC00) + ($5600 * $DF) + ($78 * $BC00) + ($78 * $DF)

And then don't forget, when you add these separate operations together, there will probably be some carrying going on.


For signed numbers: first of all, you don't need to worry about them in addition and subtraction because the z80 actually handles it all for you:
Code: [Select]
;HL + DE

add hl, de

;HL - DE

or a ;clear carry flag
sbc hl, de

Then for multiplication, before the routine runs, you need to figure out what the sign will be at the end. So 1 * 1 = 1, -1 * 1 = -1, and -1 * -1 = 1. Then convert both of the operands to positive, do the operation, and give the result the proper sign.

Changing the sign is not as simple as just XOR'ing the whole thing with %1111111 11111111. If that was true, -00 would equal FF. So the best way is to make a routine like this:
Code: [Select]
negHL:
push de
ex de, hl
ld hl, 0
or a
sbc hl, de
pop de
ret
I use that quite a bit in my math routines.

887
ASM / Re: please help me with fixed-point math
« on: May 22, 2011, 12:49:36 am »
Sorry, I haven't really been in the helping mood lately. I've been busy with my own stuff, so debugging faulty code that wasn't even written by me can just be annoying.

For 8.8 bit math, your best bet is just to use standard 16x16 bit routines and then adjust the output accordingly.

So multiplying two numbers together. 8.8 * 8.8 = 88.88. Depending on how much precision you need, you can either just take the whole part, or take both the whole part and the decimal.

From wikiTi:
Code: [Select]
mult_de_bc
   ld hl, 0

   sla e ; optimised 1st iteration
   rl d
   jr nc, $+4
   ld h, b
   ld l, c

   ld a, 15
_loop:
   add hl, hl
   rl e
   rl d
   jr nc, $+6
   add hl, bc
   jr nc, $+3
   inc de
  
   dec a
   jr nz, _loop
  
   ret

So for this routine. DE would end up being your new whole part and HL would be your new decimal part.


Division is similar. 8.8/8.8=8888. Now, you can't immediately get the decimal out of this one, but you have to remember that the division routines also return the remainder, which, if you divide that by the same number again, will get you the decimal.

Again, from wikiTi:
Code: [Select]
div_ac_de:
   ld hl, 0
   ld b, 16

_loop:
   sll c
   rla
   adc hl, hl
   sbc hl, de
   jr nc, $+4
   add hl, de
   dec c
  
   djnz _loop
  
   ret

So this returns with AC = the whole part, and HL = remainder. So just divide HL by your original DE again to get the first two bytes of your decimal.

Edit:
    Oooo, your 16 bit math routines aren't going to work at all. You have to remember that the upper and lower bits are dependent of each other. Just think of them like a two digit number. Try adding 15+36.

The right way: 6+5=11 carry the one: 1+1+3=5. So bring it together: 51

But your way: 6+5=11 don't carry the one: 1+3=4. So together: 41

This is the general concept that is making them not work, your subtract, add, and multiply functions suffer this problem, but your divide works though because it relies on an entirely different principle.

888
Axe / Re: Appvar Detection Question
« on: May 21, 2011, 12:08:13 am »
I don't know how to do it in Axe, but what you want to do is exactly what Micheal_Lee said, make all your appvars start the same way.

So for example, make all of your appVars start with Yunhua98 or something. In memory it would look like this:

Y, u, n, h, u, a, 9, 8, <level data>.

Then, using some unknown Axe command, you would search through all the appVars and look for appVars that start in that way. Those would be your levels and you would display those names.

889
ASM / Re: Please Help
« on: May 20, 2011, 08:53:11 pm »
As I said earlier on IRC, yes there is.

You can find a list of all BCalls here.

That list doesn't include ones not officially listed in ti83plus.inc. Check out BrandonW's list it has every one listed, and most of them named. (Unnamed ones are unknown as of now, so they wouldn't be useful anyways.)

And between TI's list (linked above) and WikiTi you can figure out the inputs for most of the useful bcalls.

890
ASM / Re: Please Help
« on: May 20, 2011, 07:47:37 pm »
Yes, bcall(_delMem) exists. I believe you should download this. I pull it out about every 1 out of 4 programming sessions.

And two byte subtract? sbc hl, rr. Where rr is bc or de. Just remember though that since this is sbc and not sub, you will have to make sure the carry flag is not set. So typically, you will see it used like this.
Code: [Select]
or a
sbc hl, de

891
TI Z80 / Re: [Axe Parser Shoot'em up] Devrays
« on: May 19, 2011, 08:45:49 pm »
Please, no one hate me for this, but I can honestly say that is the first Axe game that has made me say, "Wow, I wish I could help the language." This game looks great and it is very in depth. Make sure you do not let the size stop you, see if you can get CrabCake to work because if you have gone this far, I'm sure you can go farther. And for some reason if crabcakes fails on you, just PM me because I will do whatever I can to see this continue.

892
ASM / Re: Please Help
« on: May 19, 2011, 05:59:30 pm »
The header for real search would be:
Code: [Select]
;############################################
;input: a = field length
; bc = field offset from start of data
; de = start of appvar
; hl = ptr to field to match

So you can call it if you want. There are two ret's out of realSearch, the first one is the good one, where DE = the start of the data section, and the second is just an error ret.

893
ASM / Re: How are apps different?
« on: May 19, 2011, 05:51:01 pm »
This is the default one that it gives you. I would assume that if you change "MYAPP" to your app name it should work.

Code: [Select]
include "ti83plus.inc"

 db 080h, 00Fh
 db 000h, 000h, 000h, 000h
 db 080h, 012h
 db 001h, 004h
 db 080h, 021h
 db 001h
 db 080h, 031h
 db 001h
 db 080h, 048h
 db "MYAPP", 000h, 000h, 000h
 db 080h, 081h
 db 001h
 db 080h, 090h
 db 003h, 026h, 009h, 004h
 db 01Bh, 00Bh, 0AEh, 0F0h
 db 002h, 00Dh, 040h, 0A1h, 06Bh, 099h, 0F6h, 059h, 0BCh, 067h
 db 0F5h, 085h, 09Ch, 009h, 06Ch, 00Fh, 0B4h, 003h, 09Bh, 0C9h
 db 003h, 032h, 02Ch, 0E0h, 003h, 020h, 0E3h, 02Ch, 0F4h, 02Dh
 db 073h, 0B4h, 027h, 0C4h, 0A0h, 072h, 054h, 0B9h, 0EAh, 07Ch
 db 03Bh, 0AAh, 016h, 0F6h, 077h, 083h, 07Ah, 0EEh, 01Ah, 0D4h
 db 042h, 04Ch, 06Bh, 08Bh, 013h, 01Fh, 0BBh, 093h, 08Bh, 0FCh
 db 019h, 01Ch, 03Ch, 0ECh, 04Dh, 0E5h, 075h
 db 080h, 07Fh
 db 000h, 000h, 000h, 000h
 db 000h, 000h, 000h, 000h
 db 000h, 000h, 000h, 000h
 db 000h, 000h, 000h, 000h
 db 000h, 000h, 000h, 000h

894
ASM / Re: How are apps different?
« on: May 19, 2011, 05:25:21 pm »
When you write an app, you have to do some different things to make it run on the calculator.
1. Your code will be running from the $4000-$7FFF page, which means you need to do .org $4000 instead of .org $9D95
2. You need a header, (which you can get from here)
3. You will have to use bcall(_jForceCMDNoChar) or similar to return as the OS jp's to the app, it doesn't call it
4. Most bcall's that take ptr's for inputs won't work if you give them an address in the $4000-$7FFF area. What this means is that you either need to reimplement bcall(_putS) with bcall(_putC), or copy all your strings to ram before displaying them
5. Obviously, don't change port 06 unless you have copied your routine to ram


6. And most importantly, you must compile your program for hex and then sign it, I would highly suggest that you just use spasm and make the output .8xk rather than .8xp. This will save you a lot of trouble.

895
General Calculator Help / Re: Ti-84 plus operating systems
« on: May 18, 2011, 08:02:39 pm »
Yunhua98, just be sure to remember that the driver you delete is only for 32 bit operating systems. I don't know which ones you would want to delete on a 64 bit one though because I haven't had trouble yet.

896
ASM / Re: Please Help
« on: May 18, 2011, 06:43:27 pm »
Oh, yes. I forgot to change it when I was retyping it. But at least you understand it enough to realize that it was wrong :D

897
ASM / Re: about hooks..
« on: May 17, 2011, 10:48:20 pm »
Add
Code: [Select]
_enableTokenHook equ 4F99h
to your ti83plus.inc. And preferably, add it in where it fits alphabetically, just for organizing.

Sometimes brandonW doesn't always name the bcall's what you would expect. So to find that I had to ctrl + F: "tokenHook" to find the address for it in that big .inc file I linked to up top.

898
ASM / Re: about hooks..
« on: May 17, 2011, 10:35:41 pm »
Ummm... Maybe. I thought I tried that and it didn't work. But if it works for you, then good. There must be a flag or something we don't know about.

899
ASM / Re: Please Help
« on: May 17, 2011, 09:37:03 pm »
I'm not sure what areas CALCnet uses, so I couldn't really tell you. There's nothing wrong moving it to static memory though. The only problem is that you might have to modify that routine a little because it relies on the two size bytes being out front.

900
ASM / Re: about hooks..
« on: May 17, 2011, 09:29:07 pm »
Here you go. This is a sample implementation of what you want to do.
Code: [Select]
ld hl, tokenHook
ld de, smallEditRam ;nothing touches this, ever
ld bc, tokenHookEnd-tokenHook
ldir ;copy it to a place where it won't get destroyed

ld a, 1 ;1 means ram
ld hl, smallEditRam
bcall(_enableTokenHook)
ret




tokenHook:
.db $83 ;necessary for hooks, indicates that it hasn't been overwritten
push hl
ld hl, $C8*2
or a
sbc hl, de
add hl, de ;essentially, cp DE
pop hl
ret nz
ld hl, cscText-tokenHook+smallEditRam-1 ;give it a ptr 1 behind where it should be
ret ;I do not know why

cscText:
.db 4, "csc(" ;length, then string

tokenHookEnd:

If you are writing an App, then obviously you do not need to relocate this to smallEditRam. If you get some compiler errors, (you will), check this to get the equates you need. (Ctrl + F to find what you need)

Also, don't forget that just because you changed the words, it doesn't mean that you actually changed the function. For that, you are going to have to go into the scary world of parser hooks.

Lastly, I just remembered that I actually wrote a guide on this.

Pages: 1 ... 58 59 [60] 61 62 ... 108