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

Pages: 1 ... 53 54 [55] 56 57 ... 153
811
Axe / Re: Using tokens and strings together
« on: April 22, 2012, 12:24:59 am »
They're the same thing. The 'char' notation is more of a convenience/readability feature. The same applies for token values, which can be inserted with Ttoken.

812
Axe / Re: Using tokens and strings together
« on: April 21, 2012, 06:48:46 pm »
Oops, I just noticed a fatal mistake with my optimization to Lbl ABC; I forgot to add 'A' to the random result to actually make the random result in the range of letters! I fixed it now, so if you already grabbed that code, you should grab the fixed version.

813
Axe / Re: Using tokens and strings together
« on: April 21, 2012, 06:00:19 pm »
It seems that you are operating under the assumption that each list name in the string takes up 2 bytes, but they actually take up 3. The tokens themselves are only 2 bytes, but their names in the VAT are 3 bytes. Tricky, I know. But make Str8 one character longer and adjust the Copy() a bit and you should be all set.



On another note, I'll mention a few tips you could use to make this code smaller. Firstly, the letters and list names are sequential values, so there's no need to look them up from a string. You can just add an offset to the base letter/list name. Secondly, if you're only moving 1 or 2 bytes, just use a normal store, no need to use Copy(). :P

Code: [Select]
.DELSUB2
Fix 5
"var "→Str3
"L₁"→Str8
sub(LSD)
Return

Lbl LSD
rand^6→{2+Str8}ʳ
DelVar Str8
Return

Lbl ABC
rand^27+'A'→{1+Str3}ʳ
DelVar Str3
Return

814
TI Z80 / Re: Zelda resumed and almost done...a bit of help needed
« on: April 20, 2012, 11:48:05 pm »
I lied, Link's Awakening shifts 4 pixels at a time, not 8. But it doesn't really matter what amount he shifts by in the end as long as the transition isn't too fast or too slow.

815
TI Z80 / Re: Zelda resumed and almost done...a bit of help needed
« on: April 20, 2012, 09:22:15 pm »
Actually, I believe Link's Awakening shifted 8 pixels at a time when transitioning between screens. You can shift 8 pixels easily, as the shifting works out to even bytes. Although technically, since you have half the screen size, you would want to only shift 4 pixels per frame. This is easily done vertically of course, and although horizontal shifting is more difficult, you can actually shift horizontally by 4 pixels quite well with the rld and rrd instructions.

816
TI-BASIC / Re: DIM Error
« on: April 18, 2012, 05:18:36 pm »
Alternatively, here's an even smaller method that might qualify as "cheating." selectcoaxial mentioned in his first post that finding the matrix of minors is part of the algorithm to find the inverse of a matrix. But the calculator already has a matrix inverse function. So instead of going forwards in the algorithm from the input matrix, let's go backwards in the algorithm from the inverted matrix! >:D

After trying a few layouts, I've settled on this program, weighing in at a petite 45 44 bytes! :)

Code: [Select]
Prompt [A]
min(dim([A]→A
identity(A
For(B,2,A,2
*row(⁻1,Ans,B
End
Ans([A]⁻¹Ans)ᵀdet([A]


EDIT: My TI-Basic optimizing skills are a little rusty, so I didn't notice that I could optimize a parenthesis off the last line until now. This makes the size of the code 44 bytes. I won't bother to re-upload the 8xp, it's only a small change. :P

817
TI-BASIC / Re: DIM Error
« on: April 18, 2012, 02:06:36 pm »
I'm pretty sure I've developed an unbeatable method. The total size of my program's code is only 81 bytes! ;D

Most of the savings comes from the fact that I never actually find the matrix minors. Instead, I simply alter one row of the input matrix such that this matrix has the same determinant as the proper matrix minor, since that's really all we need from the matrix minor.

Without further ado, here it is in all its 81-byte glory. I've also attached the 8xp. :)

Code: [Select]
Prompt [A]
[A]→[B]
min(dim(Ans→A
For(Y,1,A
For(X,1,A
*row(0,[A],Y→[C]
1-4fPart(.5(X+Y→[C](Y,X
det([C]→[B](Y,X
End
End
DelVar [C]
[B]

818
Axe / Re: Help with freq( command
« on: April 16, 2012, 11:41:39 pm »
The Freq() command takes two arguments: wavelength and time. TBO_Yeong and linuxgeek96, I'm not sure where you got your wavelength numbers from, but neither of them appear to be correct. The approximate value that I got was 487, using this formula for the wavelength argument with middle C's frequency, 261.63Hz:

Wavelength argument = (6000000/frequency - 62)/47



Now, to deal with the time argument. The formula for this is a little more complex, since it doesn't have an explicit form, only implicit:

Desired duration = (47*time argument + 48*floor(time argument/wavelength argument) + 71)/6000000

However, if we give floor(time argument/wavelength argument) an approximate constant value instead (I'll give it about 50), we can get an explicit form:

Time argument = (6000000/desired duration - 2500)/47

If we wanted a note length of 1/4 of a second, this would give us a time argument of approximately 31900.



Putting it all together, to play middle C for about 1/4 of a second, you would use the following code: Freq(487,31900).

819
Axe / Re: Axe Q&A
« on: April 16, 2012, 10:02:54 pm »
To quote the documentation:

Quote from: Documentation.pdf
The next thing you absolutely need is an Axe Header. You must start the first line with a
period, which is a comment in Axe, followed by the name you want for the compiled
program. If you want a program description, you can type a space and then the
description on that same line, but this is optional. In the above example your program
might look like this:

Code: [Select]
PROGRAM:MARIOSRC
:.MARIO A fun platformer
:

And to quote the commands list:

Quote
#Icon(HEX) Key: identity()   Tells the parser to replace the default icon with the new icon. The icon must be 64 hex characters long.

820
Axe / Re: Isn't the 'input' function rather useless?
« on: April 14, 2012, 05:10:09 pm »
In the current state of Axe, I agree, the input comamnd is a little lacking in terms of supporting commands. It returns a string of tokens, but there are no Axe commands to handle strings of tokens...


However, you can always make your own. :) Here's a routine I whipped up to return 1 if a token pointed to is a 2-byte token, or 0 if it's a 1-byte token.

Code: [Select]
.INPUT=pointer to token
Lbl Is2B
Return inData({},[BB5C5D5E606162637EAAEF00])+255/256

You could then call this routine from another routine, like this routine I wrote to print a length-prefixed string of tokens (that's what the input command returns) to the screen/buffer:

Code: [Select]
.INPUT=pointer to first token
Lbl Print
→r₁+{-2}ʳ→r₂
Lbl PL
Return!If -r₁
Text Select(r₁,+Is2B()+1→r₁)►Tok
r₂:Goto PL

821
The Axe Parser Project / Re: Bug Reports
« on: April 13, 2012, 10:51:13 pm »
Here's a very minor bug that nobody has noticed for a long time. It's a bug with an optimization I suggested that's so insignificant, nobody (including myself) even realized that the optimization was implemented in Axe 1.0.1, until now.

The optimization was that operations on big-endian values read from a constant address, like +{°A}rr, have an optimized load in the form of ld bc,(pointer) \ ld e,b \ ld d,c. The bug is that the value of the pointer is not included, so any such operations compile to ld bc,(0) \ ld e,b \ ld d,c.

And on a side thought, now that Ar syntax exists for one-byte variable reads, perhaps Arr syntax should exist for big-endian reads?

822
Axe / Re: Axe Q&A
« on: April 08, 2012, 11:47:21 pm »
If it's only four numbers, the fastest way would be a couple of nested min() commands, like this.

Code: [Select]
min(min(A-1,B-1),min(C-1,D-1))+1

EDIT: Actually, I'm not entirely sure if this will work how you want it to. It depends whether or not you want 0 as a result if two or more of the values are 0. For instance, if the numbers were 0, 0, 1, 2, this routine would return 1.

823
The Axe Parser Project / Re: Features Wishlist
« on: April 07, 2012, 03:16:09 pm »
The Pt-Mask() routine is already really tight on register usage. Keeping track of another 16-bit value would be difficult and would require a pretty fair amount of restructuring and added size/slowness to the routine. And I feel that using non-sequential front and back sprites is not a common occurrence, so doesn't warrant this restructuring.

If you really need functionality like this, you could implement it yourself with a subroutine that copies the two 8-byte sprites to a sequential 16-byte section of RAM and then calls Pt-Mask() routine.

824
Art / Re: Type this code into your calc and get a surprise!
« on: April 07, 2012, 01:55:47 pm »
Regex'd in all the commands, fixed some bad numbers, added graph formatting commands, and converted into an 8xp. It's all set to try. :)


EDIT: For those who would just like to see the screenshot:
Spoiler For Screenshot:

825
Axe / Re: Optimization Help
« on: April 06, 2012, 11:52:36 am »
Even this is unnecessary due to the new peephole optimizer :P

It would make sense to think this, but this is actually not true. A peephole optimization to do this was added in Axe 1.0.5, but it was disabled in the next version (Axe 1.1.0) and has been ever since. Don't ask me why because I don't know; a quick test with Axe 1.0.5 appears to suggest that the optimization works fine. Perhaps I'll ask Quigibo in a more appropriate thread why this optimization (called o_PushPop5 in Commands.inc) is disabled.


Although I believe (I need Runer to confirm) that a While 1 : EndIf getKey(15) might be better than Repeat getKey(15) : End

This is true. :)

Pages: 1 ... 53 54 [55] 56 57 ... 153