+-Discord Shoutbox


Alternatively, join us on Discord directly.
You can help CodeWalrus stay online by donating here.

First Fantasy II, a graphical TI-84+CE RPG using CE Textlib hax

Started by DJ Omnimaga, March 18, 2016, 08:29:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DJ Omnimaga

Heya @Art_of_camelot nice to see you again :D. And Dudeman313 lost his CE because his parents are against calc gaming and when he got caught by teachers playing games or programming his parents just returned the 84+CE to the store and he got the school 84+. D:
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U



Dudeman313

Yeah. 
As you can see from my signature, I no longer own a graphing calculator, which means I can't play these awesome creations that everyone else is coming up with, and neither can I code for calculators in TI-Basic(the only language I know so far) away from a computer.
I do have a working build of CEmu, though, so if I can figure out my own computer's errors, I guess I could use that.

  • Calculators owned: TI-84 PCE
  • Consoles, mobile devices and vintage computers owned: Android O Phone
Does this qualify as a signature? 
The answer is "Sure."


DJ Omnimaga

So due to space concerns, I did not want to repeat my sprite loading code over and over for different purposes, and while I am ok with sub-programs, I decided to use sub-routines first to keep them to a minimum. So basically, once the program is run, I use Goto 0, and right underneath that Goto there is a Lbl leading to the said sprite loading code, followed by another sub-routine to load maps. Since goto is faster with labels located at the top of BASIC code, the speed loss is almost non-existent.

THis will enable me to draw individual sprites anywhere I want. :D


(by the way, this doesn't cause memory leaks, because I still return to the Ends I need to close with another Goto command. This is a trick explained on TI-BD or somewhere else that allows you to use Lbl and Goto for sub-routines like routineName() and Return in other languages, except you still have to specify where you want to return in TI-BASIC.)
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U

JWinslow23

I believe I've heard of something like that. Except, you don't have to state where you jump back to after every subroutine. Here is some code for a Gosub/Return-like hack.


ClrHome
Disp "IN MAIN PROGRAM

// call subroutine
For(A,-1,0
//The subroutine must not modify A!
If A
Goto SB
End

Disp "BACK IN MAIN

// main program stops here
Return

Lbl SB
Disp "SUBROUTINE
// use End in place of a return statement
// also, make sure you return at some point
// failure to do so may result in a memory leak
End

DJ Omnimaga

Doesn't Return exit the entire program, though? That's a problem when you only want to use 1 program (other than the lib).
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U

JWinslow23

Quote from: DJ Omnimaga on March 22, 2016, 11:33:39 PM
Doesn't Return exit the entire program, though? That's a problem when you only want to use 1 program (other than the lib).
Return exits the entire program...only when you get to it. If you Goto past the Return, it's fine.

I suppose you're confusing Return with End here, though. The statement that would usually mean "return from subroutine to program" is End here.

DJ Omnimaga

  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U


DJ Omnimaga

I was wondering why you suggested a return in the code above in the first place, hence my confusion :P

What I was curious about is if the SB sub-routine would need code like the following in order to go back to the label it was originally at in the game:

If A=1
Goto <back to map loading routine>
If A=2
Goto <back to boss 1 event>
If A=3
Goto <back to boss 2 event>
If A=4
Goto <back to boss 2 event B
If A=5
Goto <back to boss 2 event C
If A=6
Goto <back to boss 2 event D
If A=7
Goto <back to boss 2 event E
If A=8
Goto <back to fire magic animation loop
If A=9
Goto <back to ice magic animation loop
If A=10
Goto <back to bolt magic animation loop
If A=11
Goto <back to cure animation loop>
If A=12
Goto <back to boss 3 event
If A=13
Goto <back to boss 4 event
If A=14
Goto <back to boss 4 event B
If A=15
Goto <back to boss 5 event>
If A=16
Goto <back to boss 5 event B>
If A=17
Goto <back to final boss event>
If A=18
Goto <back to final boss event B>
If A=19
Goto <back to ending>
If A=20
Goto <treasure chest opening>


That said I could always just use other ways of course :P. For magic animations, for example, I would just setup lists of sprites ID then run through them.
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U

JWinslow23

Quote from: DJ Omnimaga on March 23, 2016, 12:32:45 AM
I was wondering why you suggested a return in the code above in the first place, hence my confusion :P

What I was curious about is if the SB sub-routine would need code like the following in order to go back to the label it was originally at in the game:

If A=1
Goto <back to map loading routine>
If A=2
Goto <back to boss 1 event>
If A=3
Goto <back to boss 2 event>
If A=4
Goto <back to boss 2 event B
If A=5
Goto <back to boss 2 event C
If A=6
Goto <back to boss 2 event D
If A=7
Goto <back to boss 2 event E
If A=8
Goto <back to fire magic animation loop
If A=9
Goto <back to ice magic animation loop
If A=10
Goto <back to bolt magic animation loop
If A=11
Goto <back to cure animation loop>
If A=12
Goto <back to boss 3 event
If A=13
Goto <back to boss 4 event
If A=14
Goto <back to boss 4 event B
If A=15
Goto <back to boss 5 event>
If A=16
Goto <back to boss 5 event B>
If A=17
Goto <back to final boss event>
If A=18
Goto <back to final boss event B>
If A=19
Goto <back to ending>
If A=20
Goto <treasure chest opening>


That said I could always just use other ways of course :P. For magic animations, for example, I would just setup lists of sprites ID then run through them.
You do NOT need ANY of that with the For() loop method, just an End ;)

DJ Omnimaga

Really? Will it really return exactly where I came from? O.O If that's the case then I'm amazed. Thanks for the tip :3=
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U

JWinslow23

No problem. The End (as far as the parser is concerned) belongs to that For() loop, and it will execute the subroutine in the first iteration, return to the beginning of that For() loop, and do nothing in the second iteration, leaving you exactly where you left off ;)

DJ Omnimaga

Ah, I understand now and this kinda makes sense while at it. Dunno why I no longer realized that the calculator was keeping track of the location of nested block/loop starting locations. >.<

In other words, this is almost exactly like real routines (or functions as they call them in certain languages), just with more limited naming abilities. That should make things easier for when I start using my sprite routine at multiple locations (I use it in map loading but I plan to also use it to draw individual sprites during battle and stuff (although for magic animations I'll probably just use big rectangles).
  • Calculators owned: TI-84 Plus C Silver Edition, TI-84 Plus CE, Casio fx-CG10, HP Prime, fx 1.0 Plus, fx-7400G Plus, fx-9750G Plus, fx-9860G, HP 39gII
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Nintendo 64, Wii U

Powered by EzPortal