### 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 - ZippyDee

Pages: 1 ... 49 50 
751
##### ASM / Re: How do apps work?
« on: March 24, 2011, 01:24:23 am »
Why does it have to be signed? (I've never understood the whole signing thing with apps)

752
##### ASM / Re: Bezier curves HELP!!
« on: March 24, 2011, 01:20:45 am »
I swear I tried that. I tried putting time in H and L and I tried both multiplying and dividing (which is why I had both Div_HL_D and HL_Times_D there). Oh well, thank you so much! And thanks for all the comments and for that other example (which is obviously 10,000,000,000 times better than mine, and way over my head)!

Can you explain what you mean about making all the numbers .256 decimal? You mean like fixed-point numbers? I was going to try to make it fixed-point, but all the scaling that's involved for the multiplication confused me, so I gave up. I also was going to try to make it write to the LCD, but I figured it's probably best to get one that just WORKS before trying to get too fancy (Well, what an ASM noob like me considers fancy).

Thanks for all your help! I'm really trying to learn to navigate ASM, and this alone has been very enlightening. It's always the small things that get you. 753
##### ASM / Bezier curves HELP!!
« on: March 20, 2011, 11:19:52 pm »
Hi, I'm quite  new to ASM, so I probably made a bunch of mistakes.

I'm trying to write a program that draws a Bezier curve based on given control points. However......it doesn't seem to be working. I think it's an issue with my math for calculating the next iteration of control points, but I've looked it over again and again and I can't figure out what's wrong. Here's the code, complete with a surplus of comments (probably more than I really need, but I just wanted to show my though processes).

//EDIT: Here's an explanation for constructing Bezier curves. Hopefully it'll help http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Constructing_B.C3.A9zier_curves

Code: [Select]
.nolist#include "ti83plus.inc"#define    ProgStart    $9D95.list.org$9D95 - 2    .db    t2ByteTok, tAsmCmp b_call(_GrBufClr) ;clear stuff... b_call(_ClrLCDFull) ld a, 255 ld (_time), a ;set _time to 255 (when used in calculation it ends up acting as a lower part of a fixed point number) ld a, (_len) ;_len is always 4 right now. That'll change once I get this thing working. ld (_level), a call LoadVals ;load the _initx and _inity values into _px and _py_tloop: call Bezier ;calculate and plot the point on the curve at _time call LoadVals ;reload the _initx/y values ld hl, _time dec (hl) ;dec _time xor a cp (hl) jr nz, _tloop ;loop until _time is zero call Plot ;plot the first point (shouldn't be necessary, but just in case) ld hl, _px ;load points at _px+(_len) and _py+(_len) into _px and _py ld bc, (_len) dec bc ;_len is the total length, so subtract one to get the last one add hl, bc ;set hl to address of _px+(_len) ld de, _px ldi inc bc ;ldi decrements bc, so add 1 to restore it add hl, bc ld de, _py ldi call Plot b_call(_GrBufCpy) retLoadVals: ld hl, _initx ld de, _px ld bc, 8 ldir retBezier: ld a, 0 ld (_n), a ;reset _n ld hl, _level dec (hl) ;go to next (or first) level iteration ld a, (hl) cp 0 jr nz, bez call Plot ;if the level is zero, draw the point at _px,_py to the graph buffer b_call(_GrBufCpy) ;display for testing purposes jr bez_ret ;end the routinebez: ld hl, (_n) ;for each point p[_n] where _n=0 to _n=_level-1 ld h, 0 ;_n is one byte, so zero out h push hl ;save _n ld de, _px ;we want to calculate the _nth byte starting at _px ;Div_pt has add hl,de in it. call Div_pt ld (hl), a ;save the new x coordinate to _px[_n] pop hl ;restore _n ld de, _py ;now we want the _nth byte starting at _py call Div_pt ld (hl), a ;save the new y coordinate to _py[_n] ld hl, _n ld a, (_level) inc (hl) ;_n=_n+1 cp (hl) jr nc, bez ;loop until _n>=_level-1 call Bezier ;call Bezier again to calculate the next level iterationbez_ret: ld hl, _level inc (hl) ;reset _level to the previous level iteration before returning retDiv_pt: ;input ; de = start address of point array ; hl = value at _n ;output ; a = p[_n]+(p[_n+1]-p[_n])*(_time/256) ; hl = address of p[_n] ;note that p[ ] is either _px[ ] or _py[ ] depending on input de value add hl, de ;find the address of the desired byte push hl pop de inc de ;de = hl+1 ld a, (de) sub (hl) ;subtract p[_n] (at hl) from p[_n+1] (at de) ;a is now the difference of the two points push hl ;save location of p[_n] ld e, 0 jr nc, _pskip ld e, 1 ;if (de)-(hl) is negative, e is 1 neg ;make a positive_pskip:;; ;This is the part that I guess isn't working ;Basically, I'm using _time as a percentage (where 256 is 100%) ;The point at _time percent of the line between p[_n] and p[_n+1] is calculated here ;    and stored in a (later stored in p[_n] back in the main Bezier routine) ;I'm calculating this: ;   p[_n]+(p[_n+1]-p[_n])*(_time/256) ld h, a ;make hl fixed point with value a ld l, 0 ld a, (_time) ld d, a ;multiply by _time push de ;save e, which holds the sign call HL_Times_D ;because HL is 2 bytes and D is one byte, this SHOULD be the same ;  as multiplying by d as if it was the decimal part of a fixed point number pop de ;restore e ld a, e cp 0 ;check for negative ld a, h ;in case of negative, get the value to invert jr z, _nskip neg ;if a was negative before, make it negative again_nskip: pop hl add a,(hl) ;add the original p[_n] value ret;;Plot: ld a, (_py) ;get the y coordinate into l ld l, a or a ret m ;ret if negative cp 64 ret nc ;ret if y>=64 ld a, (_px) ;get x or a ret m ;ret if negative cp 96 ret nc ;ret if x>=96 call GetPixel ;turn on pixel (x,y) or (hl) ld (hl), a retGetPixel: ;this came from the "Learn TI-83/84+ ASM in 28 days" or whatever guide ;a = x coordinate ;l = y coordinate ld h, 0 ld d, h ld e, l add hl, hl add hl, de add hl, hl add hl, hl ld e, a srl e srl e srl e add hl, de ld de, PlotSScreen add hl, de and 7 ld b,a ld a, \$80 ret z__gloop: rrca djnz __gloop retHL_Times_D: ;this came from the "Learn TI-83/84+ ASM in 28 days" or whatever guide ;in the guide it was DE_Times_A, but I was already using HL and D for division ;  so I thought it was a good idea to just keep those values ld a, d ld de, 0 ex de, hl ld b, 8__mloop: rrca jr nc, __mskip add hl, de__mskip: sla e rl d djnz __mloop retDiv_HL_D: ;this came from the "Learn TI-83/84+ ASM in 28 days" or whatever guide xor a ld b, 16__dloop: add hl, hl rla jr c, __overflow cp d jr c, __dskip__overflow: sub d inc l__dskip: djnz __dloop ret_time: .db 0_level: .db 0 ;control point iteration level_n: .db 0 ;control point to calculate at any given time_len: .dw 4 ;number of control points for the curve_initx: .db 4, 7, 13, 20 ;control point x values_inity: .db 6, 23, 19, 2 ;control point y values_px: .db 0, 0, 0, 0 ;x values for calculations_py: .db 0, 0, 0, 0 ;y values for calculations.end.end
If anyone could help me out that would be wonderful!

Thanks!
-Zippy Dee

Pages: 1 ... 49 50