Jump to content

Photo
- - - - -

[Scripting / 2.11] ZASM Tutorial


  • Please log in to reply
40 replies to this topic

#16 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 11 January 2007 - 08:49 PM

As I said, I keep older betas around to play quests on. I have beta 16b, mind you. I couldn't tell that there were no spaces because IPB deletes the spaces...

Anyhow, if anyone needs anymore help, feel free to ask.

#17 Snarwin

Snarwin

    Still Lazy After All These Years

  • Members
  • Real Name:Paul
  • Location:New York

Posted 15 January 2007 - 09:58 AM

To answer a question from your first post:
QUOTE
ANDR Not sure...
ANDV
ORR Also not sure... (if anyone knows, can they please tell me?)
ORV
Read all about it.

Stuff like this is really only useful when you want to keep track of (and manipulate) each bit in a register separately.

#18 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 15 January 2007 - 10:11 AM

Ah. So for example, I can use ANDR and ORR on the variable COMBOSD to check each 4th of the combo's solidity in itself? Thank you.

*adds to wealth of knowledge*

#19 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 15 January 2007 - 10:15 PM

Well, during a long Q/A session with jman, I found out a lot of things. I'll just post the chat convo...

<Revfan|Zasm> SETR d2,gd0
<Revfan|Zasm> There we go.
<Revfan|Zasm> What would that line do?
<Revfan|Zasm> As in, what is the variable: gd0
<Revfan|Zasm> ?
<jman2050> gd0-gd255 are global variables
<Revfan|Zasm> Really!?
<jman2050> that can be accessed by any script
<Revfan|Zasm> Awesome!
<jman2050> at any time
<Revfan|Zasm> So that means taht they carry over throughout the entire quest
<jman2050> thing is, ZScript uses gd0 internally at times
<Revfan|Zasm> Or just a screen?
<jman2050> ye
<jman2050> yes
<jman2050> you can also use the sd variables
<Revfan|Zasm> So they go out througout the entire quest?
<jman2050> they're basically like global variables, except they're organized per screen, per dmap
<Revfan|Zasm> And the sd variables are just for the screen, correct?
<jman2050> but the sd variables can still be accessed by any script using the SDD or SDDD commands
<Revfan|Zasm> So instead of using SETA1 and LOAD1 all the time, I can just use sd or gd?
<Revfan|Zasm> Ah.
<jman2050> yes
<Revfan|Zasm> So... As long as I use only Zasm in my quest, I am OK?
<jman2050> however, modifying another FFC's variables directly has its advantages
<jman2050> yeah
<Revfan|Zasm> Wow, that's awesome.
<jman2050> although, ZScript never touches the SD variables unless specifically told to by the script
<jman2050> so as long as you stick to using the d vars as global variables, you should be safe mixing the two
<jman2050> sd*
<Revfan|Zasm> Ah.
<Revfan|Zasm> But I don't use Zscript, however, I only use Zasm.
<Revfan|Zasm> So as long as I only use Zasm, I'm just fine, correct?
<jman2050> yes
<Revfan|Zasm> Another question: Are SD and GD saved in the SAV file?
<jman2050> yes
<Revfan|Zasm> Incredible, even.
<Revfan|Zasm> Strange triforce peice numbers have just been made several thousand times easier!
<Revfan|Zasm> Can I ask you a few more Zasm questions? I was looking through stuff the Zscript compiler produced that I am curious about.
<jman2050> go for it
<Revfan|Zasm> STOREI d2,d6 and STOREI does...
<jman2050> STOREI and LOADI store and load values using the second argument as the position of the stack
<Revfan|Zasm> Ah.
<jman2050> it's mostly used by ZScript for storing variables
<Revfan|Zasm> YOu just answered my second question as well then.
<jman2050> and loading them when neccesary
<Revfan|Zasm> But again, as long as I use Zasm, I can use them to my heart's content.
<Revfan|Zasm> I have another question about the compiler itself.
<jman2050> kay
<Revfan|Zasm> What's up with the compiler setting d2 to 0.0001 all the time?
<Revfan|Zasm> What is it's purpose?
<jman2050> I believe it's used as a boolean in those cases
<jman2050> note that near those instances, you'll see like
<jman2050> COMPAREV d2,0
<jman2050> GOTO etc etc
<Revfan|Zasm> Ah. I get it now.
<Revfan|Zasm> Another question:
<jman2050> or GOTOTRUE or GOTOFALSE rather
<Revfan|Zasm> How can I use imaginary numbers (i) in Zasm?
<jman2050> ...
<jman2050> >_>
<jman2050> what do you mean?
<Revfan|Zasm> Just set one of the registers as the square root of -1?
<Revfan|Zasm> By imaginary numbers, I mean the square root of -1.
<Revfan|Zasm> i^2=-1
<jman2050> I dunno how i would go about doing that
<Revfan|Zasm> I see it used a lot in making curves.
<jman2050> I know what imaginary numbers are icon_razz.gif
<Revfan|Zasm> Oh yeah
<Revfan|Zasm> If you couldn't tell
<Revfan|Zasm> I'm looking through compiler output of Saffith's Pong script and asking about anything I don't understand.
<jman2050> I see
<Revfan|Zasm> Ah yes.
<Revfan|Zasm> How do you set the square root of a number in Zasm? SQRV and SQRR, correct?
<jman2050> um, I don't remember if that was added
<jman2050> I think it's SQROOTV and SQROOTR though
<Revfan|Zasm> I saw SQTR or something in a list of Zasm functions.
<Revfan|Zasm> Alright.
<Revfan|Zasm> Cool.
<Revfan|Zasm> Another one
<Revfan|Zasm> MINV and MAXV, purpose/use?
<jman2050> Finds the miimum value of two values and puts he result in the firs argument
<jman2050> same for MAX, only it find the maximum value
<Revfan|Zasm> So it uses 3 arguments?
<jman2050> no
<jman2050> 2
<Revfan|Zasm> Ah
<jman2050> as always
<Revfan|Zasm> So it uses 2, replacing the first one with the lesser number.
<Revfan|Zasm> I get it now.
<Revfan|Zasm> COMBODD, I know COMBOSD has to do with solidity, but...
<Revfan|Zasm> What is stored in COMBODD?
<Revfan|Zasm> Also, for COMBOSD, how do I find the on-screen combo?
<jman2050> COMBODD returns the current combo at the position expressed by D0
<Revfan|Zasm> As in, combo number?
<jman2050> COMBOCD refers to a combo's cset
<jman2050> yes
<jman2050> COMBOFD refers to the normal flag
<jman2050> COMBOTD is the type of the combo
<jman2050> and COMBOID is the inherent flag of the combo
<Revfan|Zasm> And how can D0 hold an x/y value? The same way it did in drawing functions? (xy system)
<jman2050> no no
<jman2050> it's like the position of an array
<Revfan|Zasm> Ah.
<Revfan|Zasm> So I see it now...
<jman2050> you have to calculate it based on the X/Y values
<jman2050> that's what ComboAt is for
<Revfan|Zasm> And COMBOAT does...
<jman2050> well
<jman2050> ComboAt is a ZScript function
<Revfan|Zasm> Oh.
<jman2050> you'll have t figure it out manually for ZAsm
<Revfan|Zasm> So the combo would be 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
<Revfan|Zasm> And the next line would be 17,18,19...
<jman2050> 0-15
<jman2050> then 16-31
<jman2050> etc etc
<Revfan|Zasm> And so on, for the 11 lines of combos?
<Revfan|Zasm> Alright.
<Revfan|Zasm> Cool.
<Revfan|Zasm> Here is another question I have... More of a Zscript to Zasm conversion question.

*more on the next post*

<Revfan|Zasm> for(int i = 0; true; i = (i + 1) % 360)
<Revfan|Zasm> {
<Revfan|Zasm> this->X = centerX + radius * Cos(i);
<Revfan|Zasm> this->Y = centerY + radius * Sin(i);
<Revfan|Zasm> Waitframe();
<Revfan|Zasm> }
<Revfan|Zasm> Hmm...
<jman2050> oh lord
<Revfan|Zasm> My only real question on that is how i would go about being used.
<Revfan|Zasm> I understand the rest of it.
<jman2050> the idea is that i is set to 0 initially
<Revfan|Zasm> Hmm...
<jman2050> then it uns the code in braces
<jman2050> after it's run, it does what's in the third part of the for statement
<jman2050> well, technically, first it checks if the second statement is true
<jman2050> then if it is, it does what's in the third statement
<jman2050> and runs the code again
<jman2050> lather rinse repeat
<Revfan|Zasm> Ah...
<Revfan|Zasm> I see.
<Revfan|Zasm> And SINR, COSR, and TANR sets Cos, Sin, and Tan, correct?
<Revfan|Zasm> Sorry for throwing all of these questions at you...
<jman2050> yes
<Revfan|Zasm> One more question...
<Revfan|Zasm> Do you have that list anywhere with all of the Zasm functions and variables?
<jman2050> not a list really
<Revfan|Zasm> I know I saw an old one somewhere, but it looked like it was copied and pasted from the ZC source code.
* Revfan|Zasm finds the old list
<Revfan|Zasm> Okay, a new slew of questions *sorry!*
<Revfan|Zasm> INPUTSENABLED being set to 0 cancels all input, correct?
<jman2050> ye
<jman2050> yes
<Revfan|Zasm> ENQUEUER Does...
<Revfan|Zasm> More of a joke, but what does DUMMYCOMMAND4 do?
<jman2050> lol
<jman2050> ENQUEUE?
<jman2050> hmm, that's a new one
<jman2050> I'm not sure
<Revfan|Zasm> Well, I saw it in the list.
<Revfan|Zasm> ITEMDRAWTYPE ??? Items even have a draw type?
<jman2050> right now they don't do anything
<Revfan|Zasm> ITEMDRAWTYPE doesn't do anything?
<jman2050> no, I meant ENQUEUE
<jman2050> itemdrawtype... I forgot exactly what that refers to
<Revfan|Zasm> Hmm...
<Revfan|Zasm> FACTORIAL ??? How can I defer between V and R on this one?
<jman2050> you don't
<Revfan|Zasm> So it works wether you set a register or a number?
<jman2050> it only works registerwise I believe
<Revfan|Zasm> Ah.
<Revfan|Zasm> So FACTORIAL d0,d1 changes d0 to the factorial of d1?
<jman2050> I believe so
<jman2050> don't know what you'd need it for...
<jman2050> but yeah
<Revfan|Zasm> MODV does...
<jman2050> modulo
<Revfan|Zasm> Which would do..
<jman2050> divides one number by another and returns the remainder
<Revfan|Zasm> Ah.
<jman2050> 5 % 3 would be 2
<jman2050> cause 5/3 = 1r2
<Revfan|Zasm> So it just returns remainder, I see.
<Revfan|Zasm> Aside Factorials are useful for finding the number of combinations something has.
<Revfan|Zasm> So the factorial of 9, from what I understand, would tell you how many combinations you can arrange 9 different things in
<Revfan|Zasm> 9*8*7*6*5...
<Revfan|Zasm> Which just gave me an idea for a boss icon_wink.gif
<Revfan|Zasm> POWERV and IPOWERV do....
<Revfan|Zasm> I thought exponenets were done using XOR?
<jman2050> nope
<Revfan|Zasm> Oh.
<jman2050> XOR is exclusive-or bitwise operation
<jman2050> compare the bits of two numbers
<jman2050> if both are 0 or both are 1
<jman2050> the result is 0
<jman2050> if one is 1 and the other is 0
<jman2050> the result is 1
<Revfan|Zasm> So POWERV does exponents, and IPOWERV does...
<Revfan|Zasm> Ah. I understand xor now.
<jman2050> it;s used for things like toggling bits
<jman2050> inverted exponents
<jman2050> 1/x2
<Revfan|Zasm> hmm, another question.
<jman2050> I think...
<Revfan|Zasm> Hex numbers are preceeded with a $, so 255 would be $FF, correct?
<jman2050> yes
<jman2050> I dunno if that works in ZASM though
<Revfan|Zasm> And binary numbers would be shown as 00001100b, right?
<jman2050> might only work in ZScript
<Revfan|Zasm> Hmm...
<Revfan|Zasm> So it's impossible to use binary numbers in Zasm without doing the math on your own, correct?
<Revfan|Zasm> XD2,YD2 do...
<jman2050> acceleration
<Revfan|Zasm> I know xd is xspeed...
<Revfan|Zasm> But I thought Ax was acceleration?
<jman2050> that's ZScript I think
<Revfan|Zasm> Ah.
<Revfan|Zasm> FX,FY?
<Revfan|Zasm> Again, sorry about all the questions, if you want me to stop, just ask.
<jman2050> I think those were changed to X and Y
<Revfan|Zasm> Ah.
<Revfan|Zasm> Hey jman, I have one last question, and I'll stop pestering you.
<jman2050> kay
<Revfan|Zasm> Do Dmaps have "global" variables, or do I have to use the quest-wise one.
<jman2050> well
<jman2050> sd variables are sorta like that
<jman2050> they're on a per-screen, per dmap basis
<Revfan|Zasm> So they carry over onto other screens within the Dmap?
<jman2050> not sure what you mean by that
<Revfan|Zasm> So they use on the same Dmap, but if you leave the Dmap, they stop applying.
<Revfan|Zasm> But if you go back onto the Dmap, they continue to apply?
<jman2050> eh, like I said
<jman2050> they're just like global variables
<jman2050> in that they;re persistant throughout the quest
<Revfan|Zasm> So SD applies to a screen, and GD applies to an entire quest?
<jman2050> sorta, yeah
<Revfan|Zasm> My question is, are there any that are specific to Dmaps, that I can say, use in a particular dungeon, and that dungeon alone?
<Revfan|Zasm> Or do I have to use gd?
<jman2050> the variables are always persistant
<jman2050> so they'll be accesible whether you're in the dmap or not
<Revfan|Zasm> Ah...
<Revfan|Zasm> So sd0-255 exist on each screen
<jman2050> no no
<jman2050> sd0-7
<Revfan|Zasm> Ah.
<Revfan|Zasm> That makes sense then.
<Revfan|Zasm> However, gd has 256, correct?
<jman2050> yes
<Revfan|Zasm> Wow, just so useful...
<Revfan|Zasm> Scripts can do even more incredible things than I thought.
<Revfan|Zasm> Wait a minute...
<Revfan|Zasm> Can Zscript use the global variables as well?
<jman2050> yes
<jman2050> I think
<Revfan|Zasm> brb, I'm going to try to add all of this into my Zasm tutorial.
<Revfan|Zasm> Thanks, you've been TONS of help.
<Revfan|Zasm> Dunno what I would do without you jman icon_wink.gif
<jman2050> you're welcome
<Revfan|Zasm> One last thing *sorry*
<Revfan|Zasm> Have any ideas on my Roc's Platform?
<jman2050> hah
<jman2050> I'm kinda burned out today
<jman2050> from fixing a bunch of bugs
<Revfan|Zasm> I understand.
<Revfan|Zasm> Although, you haven't answered my question about IPOWERV
<Revfan|Zasm> What does it do differently from POWERV?
<jman2050> inverted power
<jman2050> x to the 1/y power
<Revfan|Zasm> Ah...
<Revfan|Zasm> I get it now.
<Revfan|Zasm> Thanks jman.

Long read, but hope it helps icon_wink.gif

#20 Saffith

Saffith

    IPv7 user

  • ZC Developers

Posted 15 January 2007 - 11:37 PM

QUOTE
<Revfan|Zasm> MODV does...
<jman2050> modulo
<Revfan|Zasm> Which would do..
<jman2050> divides one number by another and returns the remainder
<Revfan|Zasm> Ah.
<jman2050> 5 % 3 would be 2
<jman2050> cause 5/3 = 1r2
<Revfan|Zasm> So it just returns remainder, I see.
Something interesting to note: in most languages, you can only do modulus with integers, but because of the way numbers are handled in ZScript and ZASM, you can also do it with decimal numbers. It works the same way: 4.5 % 1.2 = 0.9.
Also, the result of a % b has the same sign as a. 5 % 2 and 5 % -2 are both 1, and -5 % 2 and -5 % -2 are both -1.

QUOTE
<Revfan|Zasm> Hex numbers are preceeded with a $, so 255 would be $FF, correct?
<jman2050> yes
<jman2050> I dunno if that works in ZASM though
<Revfan|Zasm> And binary numbers would be shown as 00001100b, right?
<jman2050> might only work in ZScript

Different set of languages. In ZScript, it'd be 0xFF rather than $FF. And yes, those both only work in ZScript right now.

Edited by Saffith, 15 January 2007 - 11:42 PM.


#21 EssenceOfHyrule

EssenceOfHyrule

    Recipient of Ways

  • Members

Posted 24 January 2007 - 04:44 PM

I'ma using b16, (tell me it's not obsolete yet) and got yonder compile error (the filename of it is testguy, and copied the move with keys instructions on the first page):

Unable to parse instruction 2 from testguy.txt
The error was: Invalid instruction.
The command was (INPUTUP,1) (,)

Gah!

Edited by EssenceOfHyrule, 24 January 2007 - 04:45 PM.


#22 ShadowTiger

ShadowTiger

    The Doctor Is In

  • Members

Posted 24 January 2007 - 04:50 PM

We probably need to see the actual text in order to proofread it. icon_razz.gif Please edit it into your previous post so we can see it?

#23 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 31 January 2007 - 10:57 PM

Hmm... Does one of the lines happen to look like this?

CODE
INPUTUP,1


Without a space in front of it? Or did you forget the space in front of COMPAREV? The spaces in front of instructions are important, as otherwise the compiler will treat it as a label.

#24 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 01 February 2007 - 08:44 PM

Just a quick note on global scripts.

Global scripts, when used correctly, can be the most powerful scripting tool, EVER. Lemme explain...

Global scripts do not loop. They end as soon as they reach the end of the script, QUIT, or WAITFRAME. There are 3 global scripts you can load:

init~ Runs whenever the game is started
active Runs every frame
OnExit Runs whenever Link dies, or the player saves and quits the quest.

These scripts are so useful because they can do things for you so you don't have to do routine functions over and over again, in quests where heavy scripting is used.

Here's a quick example:

0 GOTOR gd0
1 SETV REFNPC,1
2 SETR gd1,NPCX
3 SETR gd2,NPCY
4 SETR gd3,NPCHP
5 SETV REFNPC,2
6 SETR gd4,NPCX
7 SETR gd5,NPCY
8 SETR gd6,NPCHP
9 SETV REFNPC,3
10 SETR gd7,NPCX
11 SETR gd8,NPCY
12 SETR gd9,NPCHP
13 SETV REFNPC,4
14 SETR gd10,NPCX
15 SETR gd11,NPCY
16 SETR gd12,NPCHP
17 SETV REFNPC,5
18 SETR gd13,NPCX
19 SETR gd14,NPCY
20 SETR gd15,NPCHP
21 SETV REFNPC,6
22 SETR gd16,NPCX
23 SETR gd17,NPCY
24 SETR gd18,NPCHP
25 COMPAREV gd19,1
26 GOTOTRUE 28
27 GOTOFALSE 29
28 SETV sd7,1
29 WAITFRAME

#25 Kite

Kite

  • Members

Posted 04 February 2007 - 02:38 PM

I've moved this topic to the scripting forum. Yeah... that's about all I have to say, really. icon_razz.gif

#26 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 04 February 2007 - 03:02 PM

QUOTE(Revfan9 @ Feb 1 2007, 08:44 PM) View Post

Just a quick note on global scripts.

Global scripts, when used correctly, can be the most powerful scripting tool, EVER. Lemme explain...

Global scripts do not loop. They end as soon as they reach the end of the script, QUIT, or WAITFRAME. There are 3 global scripts you can load:

init~ Runs whenever the game is started
active Runs every frame
OnExit Runs whenever Link dies, or the player saves and quits the quest.

These scripts are so useful because they can do things for you so you don't have to do routine functions over and over again, in quests where heavy scripting is used.

Here's a quick example:

0 GOTOR gd0
1 SETV REFNPC,1
2 SETR gd1,NPCX
3 SETR gd2,NPCY
4 SETR gd3,NPCHP
5 SETV REFNPC,2
6 SETR gd4,NPCX
7 SETR gd5,NPCY
8 SETR gd6,NPCHP
9 SETV REFNPC,3
10 SETR gd7,NPCX
11 SETR gd8,NPCY
12 SETR gd9,NPCHP
13 SETV REFNPC,4
14 SETR gd10,NPCX
15 SETR gd11,NPCY
16 SETR gd12,NPCHP
17 SETV REFNPC,5
18 SETR gd13,NPCX
19 SETR gd14,NPCY
20 SETR gd15,NPCHP
21 SETV REFNPC,6
22 SETR gd16,NPCX
23 SETR gd17,NPCY
24 SETR gd18,NPCHP
25 COMPAREV gd19,1
26 GOTOTRUE 28
27 GOTOFALSE 29
28 SETV sd7,1
29 WAITFRAME


To elaborate on that, here's what it does.

It sets the X and Y position, plus the HP of the first 6 enemies on screen. It could be expanded to hold all 10, but 6 enemies is enough to work with on a screen where the script interacts with them ;P

#27 Revfan9

Revfan9

    Hero of Time

  • Banned
  • Real Name:Dr. Pajamas
  • Location:In front of a screen

Posted 07 March 2007 - 11:50 PM

An updated list of Zasm commands and variables that DN was kind enough to give me. Not everything here is implemented yet, so be warned...

EDIT: Well, I COULD have a uber-long list that stretches the page OR... I could just give a Text File icon_razz.gif

Edited by Revfan9, 07 March 2007 - 11:53 PM.


#28 Brandon1

Brandon1

    Experienced Forumer

  • Members
  • Real Name:Brandon
  • Location:Somewhere in Latin America

Posted 26 April 2007 - 07:43 AM

Oh, man, I hate Assembly, couldn't it be C++ or Delphi, but Assembly, man I still remember the headaches I got when I messed with z80.
I think I am doomed to not learn any CPU level language.

Oh and what is Zscript? Another CPU Level language or what?

Edit: I read the other thread, and I must say, ZScript sounds lots of times easier. (It looks very similar to PHP, which I am good at). I will be coding in ZScript once Zelda Classic 2.5 arrives. icon_biggrin.gif

Edited by Brandon1, 26 April 2007 - 07:47 AM.


#29 Alestance

Alestance

    Saint Alestance - Eliminator of the ZGP format

  • Members
  • Real Name:Lonk
  • Location:Pennsylvania

Posted 26 April 2007 - 09:53 AM

ZScript is like C++, so you could handle it, Brendon1 icon_wink.gif

#30 Koopa

Koopa

    The child behind the turtle

  • Members
  • Location:Switzerland

Posted 26 April 2007 - 12:59 PM

It's sort of C++, though not really object-oriented yet. But if you know some C++ you should have no problems ... commands look like
CODE
Link->HP += 4;

... you can guess what that does icon_wink.gif


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users