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

Pages: 1 2 [3] 4 5 ... 24
31
Axe / Re: A* Star and Min Heap Help
« on: July 11, 2022, 09:44:57 pm »
I took a long look through your code and couldn't really figure out how your shifting code was supposed to work. Are you trying to work around Axe's lack of a working backwards copy? It looks to me like you are pushing a node to the end of the stack and then bubble-sorting it down to its proper place. If so, it would be way easier to find the correct place to put the node, and use a backwards copy (Asm or Axe loop) to shift all the other nodes up to make room.

Here is the code I used to push a node onto the open stack for my A* implementation:
Code: [Select]
:.N2X, N2Y are the x and y of the new node.
:.N2VAL is the calculated weight of the node. Each node is 6 bytes
:
:Pxl-On(N2X, N2Y, oGB7) .I set pixels for each tile so I don't create duplicate nodes. Since my map is 64x64, drawing commands work perfectly
:Select(Open, *6+oOpenS->X) .Open holds the number of nodes on the open stack, X will now hold the pointer to the end of the stack
:If
:For()
:    {X-6}r >= N2VAL                 .Loop backwards until we come across a node that has more weight than the one about to be inserted
:    ? Asm(C1C3(L PushNext))    .If true, pop BC and goto PushNext (pop BC lets me use goto in this type of For loop. Axe won't let me use a goto in the loop so I wrote it in asm instead
:    .Once push next has been called, the function will never return here
:    .The only reason PushNext isn't in the loop is the fall-through case of the new node being the last one or an empty stack
:    X-6->X
:End
:
:.Pass through to the copy if no spot has been found
:
:Lbl PushNext   .This just sets up a backwards copy (lddr). DE, HL, BC are the same arguments (in the same order) as Axe's copy but it starts at the end and works backward
:
:Open++*6+OpenS    .Increment the count of nodes on the stack. Get the pointer to the end in HL
:Asm(E5) .push HL (will be popped as DE)
:-6 .Move 6 bytes back because we are shifting 6 bytes up
:Asm(E5) .push HL (will be popped as HL)
:+6-X .Get the total amount of bytes to move
:Asm(E5) .push HL (will be popped as BC)
:Asm(C1E1D178B12802EDB8) .Pop BC, HL, DE and copy
:
:.Copy the 6 byte node to the area pointed to by X now that everything above has been shifted up 6 bytes
:Copy(oN2VAL, X, 6) .I'm not really sure why I used copy for only 6 bytes. Maybe it was more efficient or something
:Return

While that code is very heavily optimized, a simpler version using the same logic shouldn't be too hard to implement.

Most of my Axe code isn't anywhere that nasty but I really needed a fast pathfind.

32
Axe / Re: A* Star and Min Heap Help
« on: July 10, 2022, 11:20:38 am »
You are calling DelVar correctly. If nothing is happening, then either it doesn't exist or you have memory corruption going on. And since I assume that it exists for you to know the deletion doesn't work it may be memory corruption.

As for your GetCalc issues, try displaying the value it returns when you first create it and when you have to call it again a second time. They should be the same. If they differ, something you are doing is moving memory around and there isn't anything you can do besides call GetCalc again a second time like you do.

As for custom variables holding variables to hold function labels, that is perfectly fine.
Code: [Select]
:L Label->Variable .Store the address of the function to the 2-byte variable Variable
:(Variable)(1, 2) .Call the function pointed to by Variable, passing 1, 2 as arguments. No arguments is valid
:(L Label)() .The same as doing :Label()
The L followed by the space is the little uppercase L used for getting the address of a label. I can't put subscripts in code. It should be LLabel

I don't have my calculator on me at the moment as I left it at work. I will bring it back with me on Monday and check out your A* bug then. What is your shift functions supposed to do? It looks like you are placing a node in a sorted list. Is that correct?

33
Axe / Re: Axe Q&A
« on: July 06, 2022, 08:57:31 am »
Your issue with GetCalc isn't an Axe bug. I have worked with 6+ appvars at once and had no trouble. Since all Axe is doing with GetCalc is asking the os for a pointer, it would be a ti-os bug and I very much doubt that ti-os would have such a problem. If you post your code I may be able to find what the problem was.

34
Axe / Re: Axe Q&A
« on: July 05, 2022, 09:57:35 pm »
Does Axe not allow you to manipulate more than one appvar at a time? I'm getting some really strange bugs when I do. I have 2 appvars that I create in RAM. One is the appvar for the current generated floor in my game. The second appvar is supposed to be another map that I am going to use in my AI calculation that I call DistMap. I running across several strange bugs with Axe when I do this. If I create both appvars at the same time, I am no longer able to manipulate the DistMap appvar if I do anything with the Floor appvar. In this case all I am trying to do is fill it with some value for now. If I instead create the DistMap appvar whenever I press a button (down in this case), the tilemap gets corrupted somehow. Or rather, it seems as if the 2 pointers are getting mixed up somehow. Because when I try to move down a bunch of corrupted tiles are scrolled in instead. Any ideas?

Some code to see exactly what is going on would be helpful. Here is a summary of what GetCalc( does which may be helpful.

Everything in ram is stored between 0x9D95 and the VAT which is at the top couple hundred bytes of memory. The VAT (Variable Allocation Table I believe) holds information about everything in RAM that isn't locked down to a fixed address. It also holds information on where archived stuff is in flash is but that doesn't matter for your problem. When you use GetCalc() to open an existing program/appvar/other that is in ram, what it is actually doing is going to the VAT to look up where in memory the file is and returning that pointer. Since the file is in memory, ti-os may move the file whenever needed. Any time you create or destroy a file, you should assume any pointers you got from GetCalc() are outdated and that you need to get them again. There are rules as to what moves when, but unless you are really, really hurting for speed, just do it anyway. I don't think that existing files move when you make a new one but it doesn't hurt to make sure. Resizing almost always moves stuff around.
Since each file is nothing but a reserved space in memory, simply reading/writing to it is no different than manipulating a normal area in memory. From your description of the problem my guess would be that you are resizing or creating and deleting appvars which causes them to move in memory and throws off your pointers. If you are, remember that creation/deletion/resizing can be slow because it likely has to copy kilobytes of memory around. That shouldn't cause slowdowns if you do it once or twice a second, but I would avoid it in a loop. I would suggest using existing memory areas before resorting to appvars. There is a lot of built in memory if you look. Take a look at this if you want to to beyond what Axe's L1-L6 give you. It is pretty outdated in where it says Axe's variables are located so ignore those. For example 0x8000 gives you 256 bytes of memory and as long as you don't turn your calc off, it is perfectly free to use. (although it overlaps somewhat with the 756 byte buffer L4-512)

Here are some other fun facts that probably won't help you but may be interesting:
Appvars and programs are the same thing (as far as I know) and they only differ by one byte which tells what they are.
Pretty much any name is legal for a program/appvar as long as you don't intend on interacting with it through ti-os. You can make and edit programs with lower case names. Axe will even allow you to include and compile programs with lowercase names just like normal ones. Ti-os won't let you run a program with a lowercase name but as long as you compile to an uppercase program you will be fine. When transferring these programs to and from a computer, the ti-connect will irritatingly capitalize all the names.
"prgm#" and "prgm!" are special programs that hold recently entered stuff on the home screen. I don't remember exactly what each one does, but they exist. I'm not 100% sure on their names but I'm pretty sure those are it.
When you run a program, it gets moved to 0x9D95 (0x9D93 is the 2-byte size of the program) and then executed. So if you want to run a program from within an app, you can copy it there and just :Goto E9D95. Since there could be appvars there already, you should use some calls that aren't part of standard Axe to move anything that is there out of the way.

35
Math and Science / Re: A faster Newton's Method Square Root
« on: June 30, 2022, 08:54:36 pm »
Unless I am reading this wrong, float64's (or doubles as I will call them) get between 15 and 17 digits of precision compared to the 14 of a 9 byte BCD float. Wouldn't it be easier to use doubles then? Any 14 digit number the user enters can be represented perfectly. Sure, there will be some precision the user doesn't see but isn't that already the case since the OS only prints out 9 (10?) digits? I can't think of case where a double would cause a rounding error where a BCD wouldn't also. And that isn't taking into account that the OS uses 9 bytes and not 8.

Off topic note because I can't be bothered to find my Discord login: what emulator do you use? I have always used Wabbitemu but it tends to crash when I mess with flash.

36
Math and Science / Re: A faster Newton's Method Square Root
« on: June 29, 2022, 09:17:22 pm »
That is pretty neat! In all your dealing with floats did you come across a reason why ti-os uses 11 byte BCD floats? (with one whole byte for sign IIRC)
Is it just because BCD helps prevent any incremental errors?

Its a pity that I have (pretty much) finished my big z80 projects because there is several places I could have really used some floating points. I'm terrified by how close it's average of 1165 cycles is to a workaround I made a while ago using abs, min and max to calculate distance. I really need to set aside a weekend and add in floating points.

Testing gave me an average of 800 cycles for Axe's 16 bit integer square root. That's not much slower than your 32 bit floating point square root. Do floats just lend themselves to that kind of math?

Your link to GMP is broken...

37
Introduce Yourself! / Re: Hello!
« on: June 28, 2022, 08:36:00 pm »
Welcome! And here are some obligatory peanuts:
!peanuts

Zeda and myself are probably the two most active members with experience in Axe. Somehow I always manage to show up late to all the Axe related questions though. I blame Zeda for being too fast.

38
Ndless / Re: Ndless sdk toolchain not building
« on: May 15, 2022, 08:39:29 pm »
I googled and found this github page. I assume that is what you are using.

I'm not sure what the sdk is supposed to do, but I went ahead and just tried to get that file to run. I have a Debian partition and not Cygwin so any differences may of course be caused by the OS. I had a couple errors from libraries that weren't installed but after I installed them it got started for me. It errored out after ~30s of compiling due something or other. But it spit out a bunch of text.

I would suggest adding an echo to various lines so you can see how far it gets before exiting. That may give you an idea of what is causing the problem. Alternatively you can try setting up a virtual machine or using WSL and see if either gives better results. I haven't messed with Cygwin but I kinda doubt that it is the problem by itself but a fresh start may work if there is some system config that is causing the problem. If you give me a more detailed account of what you did I may be able to be more helpful. I don't know if @Vogtinator is still around...

Off topic, but why did you choose Cygwin over WSL?

39
Axe / Re: Looping Through an Array in Axe
« on: February 19, 2022, 07:20:09 pm »
@Ki1o
Wow... that's... the most beautifully formatted Axe code I have ever seen. It's not super efficient but who cares for level generation anyway. (and why ruin a work of art?)
I assume by [r1] you mean r1 and not {r1}.

I can't put my finger on the problem without the full source but I do see one thing that might be causing the problem.

In Connect to you do:
Code: [Select]
:If [r1]=°Below
:...
:Stuff
:...
:End
:If [r1]=°Right
:...
:Other stuff
:...
:End
You call subroutines in the first if block which modify r1. By the time you get to :If [r1]=°Right, r1 almost certainly doesn't hold its original value.


Here are a couple wild guesses and observations. They probably aren't right but who knows? Maybe...

The line :If AdjacentRoomY-1-{°RoomY+Room}+{°RoomHeight+Room}>4 bugs me. Do you want :If abs(AdjacentRoomY-1-{°RoomY+Room}+{°RoomHeight+Room})>4 ? I don't know what kind of values you are expecting but if you get -1 it will underflow to 65535 and return true. Values < -4 will act like expected but -1, -2, -3 might be a problem if they can ever happen.

The lines :Rand()^1->P :If P   don't do anything since any number ^1 is 0. I get it is probably for debugging but I thought you might have meant ^2 instead. The optimizer in me compels me to tell you that :If Rand() ^ 1 would be the same as those two lines and wouldn't use a variable. (But again, you probably already know that)

Once, when I was working on random level generation, I came across a bug that had me tearing out my hair for a week. I tracked it down to (usually) a crash when writing to OP1 which is free scrap memory. It moved around quite a bit - making it extra confusing. The crashing code was used many other places and didn't have any attached special conditions. I eventually found out that it was zStart's custom font causing Axe to incorrectly compile my code. I turned off my custom font and everything worked fine. (I had used that font for years by then and all 16 other programs in that project compiled perfectly - making it super weird) If you have a custom font, try disabling it. If Axe's font doesn't screw up and show garbage during compilation then you are fine. (It had done that for that specific program for years at that point so I didn't think anything of it)

I'm not super familiar with Axe's 3 argument For loop because I always use the 1 argument (because I am horny for optimizations) but it looks like in Connect you are filling 1 extra byte in the Fill command compared to the For loop.

If all else fails, try adding code to Connect to check every byte to make sure it is in bounds before writing it. If out of bounds, pause and display variables. Also draw the whole map in pixels to the screen every write (and maybe even slow it down so you don't miss anything) and make sure it is doing what you want.

40
Axe / Re: Questions with commands
« on: February 19, 2022, 06:30:30 pm »
hello
i just started using axe yesterday and wrote a simple program, and don't understand how "if" works. I've come here from Ti basic
here is my code
input"BRUH"->Str1
"BRUH"->Str2
GetCalc(Str2)->A
GetCalc(Str1)->P
If P=A
Disp"YAY"
End
!If P=A
Disp"NO"
End

I want it to only display "YAY" when "BRUH" is input, but for some reason it always outputs "YAY" no matter the input.
i am confused

@chucktheduck
Transitioning from BASIC to Axe is a pretty big jump. Although Axe's syntax looks like BASIC, it works in a completely different way. Very, very few segments of code work in both Axe and BASIC. You should be familiar with how pointers work. If you aren't, you should really spend 10-20 minutes reading about them because Axe uses them heavily. If you don't understand them, Axe will be one frustrating mess to use.


Code: [Select]
input"BRUH"->Str1 While this is valid syntax, it won't do what you think it does. It actually translates to:
Code: [Select]
:input
:"BRUH"->Str1
Which means it gets the user's input, does nothing with it and then stores the pointer of the string "BRUH" to Str1. Names like Str1 or GDB1 are constants. Their value can't change once the program has compiled. (The data they point to can change) This means they can't hold any value that you can't figure out when the program is compiled. Use variables to do that instead. Doing input->Str1 won't work because the value input returns may change, instead you need to use a variable like A. So: input->A


input returns a pointer to tokens. Tokens are different than characters because they can be 1 or 2 bytes long. I won't explain how they work because it is a bit complex. But if you stick to uppercase letters and numbers you will be safe because they are all 1 byte.

When debugging it is always useful to print the values of variables. Even if you are sure what they are, it is never a bad idea. :Disp A will try to print a string so it will look like gibberish. Instead, use Disp A>Dec to display it as a number. In your case, no matter what you input A and P will both hold 0. GetCalc returns a pointer to a file if the file exists in RAM or 0 otherwise. GetCalc("YAY") or GetCalc("BRUH") both return 0 because there is no file with either of those names. (So P = A) Files are things like "prgmTEST" or "appvSOMEDATA" You can use GetCalc to read and write to programs and appvars. I'm not sure what you are trying to do with it, but the documentation for it isn't very clear so I assume you misunderstood what it does.


Here is some code that should do what you want. I haven't tested it but I'm pretty sure it will work.
Code: [Select]
:.Comments start with a period. You don't need to include them in your code
:input->A            .Get a pointer to the entered tokens
:"BRUH"->Str2        .Get the pointer to the characters B, R, U, H. This line can be put anywhere in the program and it will function the same. I like to put my data at the end but that is up to personal preference.
:                  .If you want to test if two strings are equal, you need to loop over them and compare every byte.
:0->X                  .X holds where we are in the string. To compare equality, you need to loop over every byte in the string and compare it. (This is what other languages do too, they just hide it from you)
:1->Y                 .Y holds 1 for true. If we find an inequality, we should set it to 0 because the strings aren't equal
:For(length(Str1))         .Loop for the 'length' of Str1 Since input returns tokens and not characters, this may not work correctly if you use anything besides uppercase letters and numbers. (I won't explain why now because tokens are pretty complex)
:                              .The single argument for loop just runs the given amount of times. For(5) will run the body of the loop 5 times.
:!If {A + X} = {Str1 + X} .If the characters aren't equal save the value 0 to Y so we know they aren't the same
:0->Y
:End
:X++            .Increment X to the next character
:End
:
:If Y            .If Y is not 0 then the strings are equal
:Disp "YAY"
:Else
:Disp "NO"
:End


Additionally you can use Equ>String(A, Str1) to do the same thing as the loop. It is a good idea to understand how the loop works. Note that Equ>String returns 0 if the strings ARE equal and non zero if they ARE NOT.


If you haven't already, install a shell like zStart or DoorsCS7 to allow you to edit your code from archive. (this isn't a recommendation, its practically a must) Messing up in Axe means your calculator resets RAM so any programs left there will be deleted. I recommend zStart because it lets you press ON+Zoom to compile and run your code from within the editor as well as use ON+Vars to show a list of all Lbl's that you can then teleport your cursor to. Much easier than Alpha scrolling for large programs.


That was a lot. Hopefully I explained it all clearly. (If not, I am happy to explain more - I get really excited talking about Axe!)

41
Axe / Re: Looping Through an Array in Axe
« on: December 15, 2021, 07:31:06 pm »
I agree with Xeda about the parenthesis. I did notice you called main() and didn't return after that. Instead you fall through and run main() a second time and quit the program with its return. Since all main only does something when you hit enter, it shouldn't matter. Without picking through your logic, I can't say more.

Here are some tips for your code. What you have will work, but there are better ways for some things.

I would strongly recommend using the ? and ?? operators for 'and' and 'or'. The 'and' and 'or' you are using are bitwise. This means "1 and 2" returns false. The ? and ?? operators work like && and || in C and even short circuit which is nice. (the same left to right order of operations still apply) This means you can rewrite:
Code: [Select]
If (RoomX≥XMin and RoomX≤XMax) and (RoomY≥YMin and RoomY≤YMax)as
Code: [Select]
If RoomX≥XMin ? (RoomX≤XMax) ? (RoomY≥YMin) ? (RoomY≤YMax) .I omitted the first pair of parenthesis because of order of operations. You can add it in if you want, it will be compiled out
Using →→ is the same as → if the constant hasn't been declared before. No reason to change it if you don't want to. Just be careful you don't double declare constants as you won't get an error!

You can chain constant declarations together to make them easier to read.
Code: [Select]
L₄+12→→°XMin
L₄+14→→°XMax
L₄+16→→°YMin
L₄+18→→°YMax
L₄+20→→°Rooms
can become
Code: [Select]
L₄+12→°XMin+2→°XMax+2→°YMin+2→°YMax+2→°Rooms
Nice work on making a custom text routine! If all you are after is speed and flexibility, I made a super fast text axiom that can draw to any buffer.

As for putting rooms in the map, making a rectangle collision routine would probably make things a lot smoother. Here is one, I haven't tested it, but it is a translation of one that I wrote in C so it should work. It assumes the rectangles are in the format top_left_x, top_left_y, width, height.
Code: [Select]
Lbl Intersect
...
Since each rectangle is made of 4 points and we only have 6 parameters max, I will use A, B, C, D for the second rectangle. Change them to whatever you want
r1, r2, r3, r4 = the first rectangle
A, B, C, D = the second rectangle
returns 1 if the 2 intersect anywhere
...
max(r1, A) < min(r1 + r3, A + C) ? (max(r2, B) < min(r2 + r4, B + D))
Return

42
TI Z80 / Re: Elimination: An RPG inspired by Earthbound / Pokemon
« on: October 25, 2021, 05:40:41 pm »
That's pretty cool. Writing a project that large in asm must be really time consuming. Less than 10 app pages? That seems kinda large. My biggest project comes out to almost 16 pages but that is because it was compiled in Axe and is in greyscale. Do text and sprites eat most of that?

43
Other Calculators / Re: Darkblasters: A new graphical TI-84+/SE BASIC RPG
« on: September 22, 2021, 05:42:22 pm »
This looks great indeed!
I wonder, would it be possible (not too hard) to port it to the 'TI-84 Plus CE Color' to show us some of the game "true colors"?

I doubt a port would add much since the sprites are done by mixing characters. Also I think I remember hearing somewhere that 84ce text characters include a white background that would ruin it. But I dont have any color calcs so I don't know too much about them.

44
Other Calculators / Re: Darkblasters: A new graphical TI-84+/SE BASIC RPG
« on: September 12, 2021, 04:21:15 pm »
11k is really small. Maybe I inflate my Axe source file sizes with long variable names and lowercase but I can't make anything near that functional in that size.
Is there a saving system?

45
Other Calculators / Re: Darkblasters: A new graphical TI-84+/SE BASIC RPG
« on: September 08, 2021, 08:33:33 pm »
That is some seriously nice graphics for basic! I definitely thought you were using an asm library. Also, (c)2091? That's optimistic... or perhaps pessimistic. I guess it depends on what you are aiming for.

Pages: 1 2 [3] 4 5 ... 24