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

Pages: 1 ... 51 52 [53] 54 55 ... 317
781
Axe / Re: Problem with shooter code
« on: August 06, 2013, 08:55:05 pm »
For the AI, all I did was have it randomly move toward the user. As an example, if playerX>enemyX and rand^2 (which returns 0 or 1) is 1, then do enemyX++

782
Axe / Re: Problem with shooter code
« on: August 06, 2013, 05:39:19 pm »
That looks great! I was in town earlier today with no obligations, so I programmed for a bit and converted my BASIC code to Axe and then modified it a little. It currently only does one bullet at a time, but I am going to add in code to have a bullet buffer. I managed to figure out a way to make sure bullet movement was not bugged except for one case with an acceptable bug (I think). Shooting vertically will cause it to shift 1 pixel off course, but I don't think that should be a problem. Anyways, see the screenshot :)

EDIT: Updated the code, now it uses a bullet buffer. It currently handles 64 bullets on screen at a time and it is still at 6MHz. Feel free to use any of the code or look at it or whatever!

783
Axe / Re: Problem with shooter code
« on: August 05, 2013, 11:53:11 pm »
This is the BASIC line drawing routine (I don't have easy access to my calculator at the moment, so this is just what I wrote in my notebook):
Code: [Select]
;draw from B,C to D,E (b=x1)
D-B→D
E-C→E
1→F:1→G    ;these are the xinc and yinc
If D<0
-1→F
If E<0
-1→F
abs(E→E
abs(D→D
If not(Ans
Then       ;draw a vertical line
For(A,C,C+E,G
Pxl-On(A,B
End
Return
End

D→A
2D→D
2E→E
For(H,1,.5D
Pxl-On(C,B
B+F→B
A-E→A
While A<0
C+G→C
Pxl-On(C,B    ;ideally, this should come first and be skipped on the first iteration of the loop, but this isn't that easy in BASIC
A+D→A
End
End
Pxl-On(C,B


In this part of the code above:
Code: [Select]
While A<0
C+G→C
Pxl-On(C,B    ;ideally, this should come first and be skipped on the first iteration of the loop, but this isn't that easy in BASIC
A+D→A
End
To work better, it should be more like this in Axe:
Code: [Select]
If 0
Lbl 01
Pxl-On(B,C
End
C+G→C
A+D→A
If <0      ;well, change this to the proper Axe syntax
Goto 01
End
That skips the first pixel plotting which is only a problem if you are inverting the pixels. Hopefully you can derive a working algorithm from this!

784
Axe / Re: Problem with shooter code
« on: August 05, 2013, 11:19:00 pm »
Hmm, I recognise the problem, but I did not see the issue in your source code immediately. Hopefully I will take a look at it tomorrow and possibly figure out the issue.

I would also like to point out that you can do signed comparisons. For example, {J-6}<<0 to see if it went below zero. I think Axe probably does an auto-optimisation for that.


I tried my attempt above and found that it doesn't work (I forgot some of the nuances of Axe x.x). I did get it to work in BASIC, though.

785
TI Z80 / Re: gCn picker
« on: August 05, 2013, 06:34:13 am »
Wow, that is pretty cool, Sorunome o.o That makes it look rather easy to use!

786
Axe / Re: Problem with shooter code
« on: August 04, 2013, 11:59:46 pm »
Hey LemonDrop, I am not sure if this is the Bresenham method, but this is a line drawing algorithm I came up with a few years ago that is fast and easy to implement in Axe, Assembly, BASIC, Grammer -- you name it. Modified, instead of drawing a line, you can make a bullet follow a trajectory. This will also work smoothly using the the inflated coordinates that shmibs was referring to (this is an excellent technique, especially when you start doing physicsy things) or just the regular 96x64 pixel area. Anyways, the basic pseudo-code looks like this:
Code: [Select]
;Given : (x1,y1) and (x2,y2)
x2-x1 → width
y2-y1 → height
1 → xinc
1 → yinc
If width>0
1 → xinc
Else
-1 → xinc
-width → width
If height>0
1 → yinc
Else
-1 → yinc
-height → height
If width=0
y1 → count
while count <= y1+height
plotpixel(y1,x1)
x1+1 → x1

else
width → accumulator
width*2 → width
height*2 → height
0 → count
while count < width
plotpixel(y1,x1)
y1+yinc → y1
accumulator - height → accumulator
while accumulator < 0
x1 + xinc → x1
plotpixel(y1,x1)
accumulator + width → accumulator
plotpixel(y1,x1)
While that may look complicated, it actually simplifies quite a bit when put in use. To describe the algorithm, there is an accumulator that starts at 1/2 the width (because we are using integers, I store the width to the accumulator and then double width and height, so the accumulator is half the width). Then at every cycle, a much more general algorithm might increment y and add height/width to to x. However, we cannot use non-integers, so we need to be more clever. This is why I have an accumulator. What we could do is add height to the accumulator and if the acc>width, then we need to increment the x coordinate. To determine how many times we need to increment, just subtract accumulator-width until accumulator<width, each time incrementing x and plotting a pixel. In the algorithm above, it is more optimised for assembly and instead of doing accumulator+height, I do accumulator-height until accumulator<0 (which the processor automatically recognises without needing to do a compare).


Anyways, now for some actual Axe code! (Note: I am not a very knowledgeable Axe coder, so there may be many optimisations to be had!) The first thing we are going to need to take note of is that we aren't drawing a whole line at once (unless you are making a laser effect) so it will be more useful to make a subroutine that returns the coordinates of the next pixel. As well, in the event that we have multiple bullets on screen, we might want to make the routine even more flexible to work with a buffer of bullet data so that we don't tie up variables.
Here we go:
Code: [Select]
Lbl BNEXT
.IN: Ptr
.accumulator,dir,x,xinc,w, y,yinc,h,counter
{r1}→r3
!If {r1+1}
r1+4→r1
{r1++)→r2+{r1++)→r2
r3-{r1++}→r3→{r1-8}
r3<<0→{r1-7}
Else
r1+1→r1
{r1++)→r2+{r1++)→r2
r3+{r1++}→r3→{r1-5}
r3<<0→{r1-4}
r1+3→r1
End
{r1-5}→X
{r1-2}→Y
If {r1++}--
Return
End
r1-8→r1


Lbl DELB
.REMOVE THE BULLET
Return!If {GDB1)
Exch(GDB1Z,r1,9)
{GDB1}--
Return

Lbl ADDB
.IN: (x1,y1,x2,y2)
ReturnIf {GDB1}=10
{GDB1}++→r6*2*2*2+r6+GDB1-9→r6

r3-r1→{r6++}→r5=0→{r6++}
r1→{r6++}
0→{r6++}
If r6>0
1→{r6}
ElseIf r6>32767
-1→{r6}
-r5→r5
End
r5→{r6++}
r5→{r6+4}

r4-r5→{r6++}→r5=0→{r6++}
r2→{r6++}
0→{r6++}
If r6>0
1→{r6}
ElseIf r6>32767
-1→{r6}
-r5→r5
End
r5→{r6++}
Return

I have not tested that code, so I doubt it will work, but just in case it does, GDB1 should point to a buffer large enough to hold the bullet data (in the code above, it limits to 10 bullets, so 9*10+1 = 91 bytes). This buffer should be zeroed, and GDB1+9*9+1→GDB1Z should be defined (GDB1Z points to the last bullet).
The 3 routines, if they work, are:

BNEXT(ptr) : ptr points to 9 bytes of bullet data. Returns X,Y as the coordinates of the bullet.
DELB(ptr)  : ptr points to the 9 bytes of the bullet data to remove from the bullet buffer.
ADDB(x1,y1,x2,y2) : If there is room on the bullet buffer, the bullet trajectory is added.

As a note, BNEXT automatically removes the bullet if it reaches its destination coordinate. If you want it to continue past the destination until it goes offscreen, the code can be modified.


I hope it works, but I am too tired to test it tonight. I need sleep :P

787
WHAT THE WHAT?!    :w00t:  Sounds for games with no hassle...    :hyper:
Well, we don't know yet how easy it is to communicate with the Orion component through assembly. As well, I would imagine that much of the sound is preloaded onto the Orion device, but it might be neat if you can pass text to it and it reads it.

Also, $600.

788
Yeah headphones might be a concern if someone writes a counterfeit copy of an existing program allowed at a test that actually tells the test answers with headphones plugged in or something. However, no headphone support might be annoying for other students who constantly hears a calc talking.
Oh, I hadn't even thought of that o.o I was more thinking about during math tests, without headphones your calculator would be telling all of your answers out loud.

789
So... I am assuming headphones are used during tests? TI does tend to be worried about that kind of thing :P

This is pretty cool, though :) The speech is actually pretty decent, I think.

EDIT: Also, I think that if I ever go blind, I could still use my calculator just fine >.> I do the math in my head, anyways, and I otherwise know where everything is.

790
TI Z80 / Re: Jade
« on: July 29, 2013, 11:08:21 am »
I haven't added in any of the shell parts that I wanted to add in, yet, but I did rewrite parts of the graphics code. I am emulating the screen with a different approach and that allowed me to make a slightly faster LCD update routine and a much faster clipped sprite routine. The end product is about a 23% speed boost in my pong example :)

Also, going through the code, I think I can try to give it much better organisation and possibly reduce the size and increase the speed. It is quite a mess at the moment.

791
TI Z80 / Re: CopyProg
« on: July 29, 2013, 06:55:00 am »
I did not have any issues when I tried it and I tried values of R from 0 to 7 (at this point, it just kept returning the last line as it should). I tried it with the program archived and unarchived and it didn't make a difference, so maybe I forgot to upload something...?

792
Casio Calculators / Re: [Prizm C] Mandelbrot Set
« on: July 28, 2013, 10:36:27 pm »
Oh my gosh, I totally want to learn enough ARM assembly to do that on my NSpire o.o

793
TI-BASIC / Re: Check if two "occurences"
« on: July 28, 2013, 03:26:25 pm »
If you use multiple arguments, the first list gets sorted, the other lists get their elements swapped around so that they stay with the elements in the first list. So if you want to make sure that the lists are set back to the same order they were in, you can do:
Code: [Select]
cumSum(binomcdf(dim(L1)-1,0→L3
SortA(L1,L2,L3
min(not(ΔList(L1) or ΔList(L2
SortA(L3,L1,L2
And that returns 1 if there are any duplicates, 0 otherwise, and keeps L1 and L2 unchanged.

794
TI-BASIC / Re: Check if two "occurences"
« on: July 28, 2013, 03:16:34 pm »
Hmm, maybe something like this? :
Code: [Select]
SortA(L1,L2
sum(not(ΔList(L1) or ΔList(L2

EDIT: This assumes the lists have more than 1 element. Also, nice idea with the matrixfeytontias stuff.

795
Casio Calculators / Re: [Prizm C] Mandelbrot Set
« on: July 28, 2013, 01:16:17 pm »
It took 46 seconds at 94.3MHz, but about 75 seconds at normal speed.

Pages: 1 ... 51 52 [53] 54 55 ... 317