CYCODE WORKS!!! Visit the new forums
http://destiny.cerberusstudios.net:8080/forum/index.php
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages    Log inLog in 
  GamesGames   


Bookmark this site!
CYCODE WORKS!!!

 
Post new topic   Reply to topic    Visit the new forums Forum Index -> CyFyre development and implementation
View previous topic :: View next topic  
Author Message
Super_Llama
Lead Scripter
Lead Scripter


Joined: 04 Jun 2007
Posts: 1503
Location: The Krypton Zoo

PostPosted: Tue Feb 10, 2009 4:34 pm    Post subject: CYCODE WORKS!!! Reply with quote



The above image is a screenshot of the Visual Basic Cycode Prototype in action. This nearly complete prototype of the Cycode queue interface works perfectly and is very efficient. It can load multiple scripts at once, and serves as a good testing box for cycode until sheo and I can port it to C++ and put it in the game.

in other words... IT WORKS IT WORKS IT WORKS!!! Very Happy

Now let's have a look at the Cycode Assembler once more. I've made ALOT of changes, a few by suggestion of sheo (pstr 1, 2, 3 anyone?).



Let's have a look at the cyasm that went into this program.

Code:
stab 13
  str InputScript
  str Lawl, you just launched me!
  str You inputted:{space}
  str Cycode Input Test
  str - type list for options -
  str about
  str exit
  str list
  str =COMMAND LIST={enter}  about - show the about messagebox.{enter}  exit - end cycode.{enter}  list - this message.{enter}  time - what time is it?
  str Welcome to the Visual Basic Cycode Prototype! This standard input cycode file should always be loaded first as it provides basic functionality. You'll notice that you can quite easily have lots of scripts running at once, and you can test launchable{space}
  str scripts using the Script->Launch feature. Try launching this script! It's called 'InputScript'. Have fun, and keep coding!{enter}  -Super Llama{enter}{enter}P.S. This message was so long that it wouldn't fit in one string entry! XD
  str -Advanced Input Script-
  str time
etab 4
  eload adr_load
  elnch adr_launch
  eccin adr_console_input
  esect adr_second_tick
dtab 2
  map debug
  map win32
titl 0
end
mark adr_launch
  pstr 1
  call console.print
end
mark adr_console_input
  call console.input
  pstr 5
  steq
  jeq show_about

  call console.input
  pstr 6
  steq
  jeq exit_program

  call console.input
  pstr 7
  steq
  jeq commandlist

  call console.input
  pstr 12
  steq
  jeq timeoutput

  call console.input
  call console.input.clear
  pstr 2
  call console.print.direct
  call console.print
;Endb is exactly like end, but the loader doesn't notice. Basically,
;if you use end, any code afterward will be completely ignored unless
;an event points to something after the end. 'end' tells the header to
;stop saving to a queue, and go to the next event. If you're trying to
;put special cases (like I have below) then use endb so that they will
;be put in the queue, otherwise you won't be able to use them through
;jumps (gotos).
  endb
  mark show_about
    pstr 11
    jstr 9, 10
    call windows.message.titled
    call console.input.clear
  endb
  mark exit_program
    call windows.exit
  endb
  mark commandlist
    pstr 8
    call console.print
    call console.input.clear
  endb
  mark timeoutput
    call system.datetime
    call console.print
    call console.input.clear
  endb
end
mark adr_second_tick
  call windows.beep
end
;NOTE: The load queue is never actually stored. The code is executed directly after the header is processed, and then disposed of.
mark adr_load
  pstr 3, 4
  call console.print
  call console.print
  call console.input.show
  call console.input.enable
end


First of all, you can now precede a line with spaces, and it wont' care. Yay, now we can make indents XD
Also notice the COMMENTS!!!
;comment
Yaysies. There are now 5 queues you can point to in the etab:
elnch (replaced lnch) -> the launch queue, where each script is processed separately from a launch pointer in another script.
eccin -> cyconsole input. the entire queue is run when the user presses Enter in the cyconsole's input box.
eload -> the load queue. the load queue is special, since it isn't really a queue. the executor reads this queue directly out of the code file after the header has been processed.
esect -> every second tick. the entire queue is run every second. too much stuff here is dangerous as it can cause regular pauses each second, and that gets really annoying.
etick -> every tick. the entire queue is run as often as possible. use sparingly.

soon I'll add:

esprd -> the spread queue. code here is spread over many ticks.
efunc -> the function queue. code here is executed by other queues. endb will have to be used alot here. example:
Code:
stab 6
 str FunctionExample
 str Type something.
 str How many letters are in the word llama?
 str That is correct.
 str I think you'd better re-learn your numbers.
 str Do numtest?
etab 2
 efunc functionqueue
 elnch launchaddress
dtab 1
 map win32
titl 0
end
mark launchaddress
  ;function calls work by a proper string name. arguments can be passed using the argument stack, as it is public with the exception of the spread queue (whose stack will be appended to the public one in case of a function call, and popped off if unhandled)
  fcall repeatinput
  pstr 5
  call windows.message.yesno
  pint 1
  steq
  ;compare the return push of yesno (yes=1, no=0) with int 1 (yes), and function call if equal (fceq)
  fceq numtest
end
mark functionqueue
 func repeatinput
   ;points to 'str Type something.'
   pstr 1
   ;windows.input pushes the input onto the argument stack, and windows.message uses it. no need to pstr the windows message.
   call windows.input
   call windows.message
 endb
 func numtest
   ;'str How many letters are in the word llama?'
   pstr 2
   call windows.input
   ;compare the input to the int 5 through steq (stack equality)
   ;steq will pop the values off the stack and store their equality in the cmp variable for use with other functions (jeq, etc)
   pint 5
   steq
   ;both values are gone now; the number that the user typed, and the int 5 that was pushed.
   jeq adr_correct
   ;if the jeq is not satisfied, this will be called. otherwise, it will jump to adr_correct.
     ;'str I think you'd better re-learn your numbers.'
     pstr 4
     call windows.message
mark adr_correct
   ;'str That is correct.'
   pstr 3
   call windows.message
 endb
end



In case you're wondering, this is what the hex code looks like:


This probably looks really scary. The easiest possible script is the infamous hello world:

Code:
; ==HEADER== ;
;string table. store the title (HelloWorld) and the text (Hello, World!)
stab 2
  str HelloWorld
  str Hello, World!
;event table. point elnch (launch) to adr_launch.
etab 1
  elnch adr_launch
;map table. its very complex but all the hard stuff is automated, just think of it as 'includes'. 'map debug' tells the reader that it uses functions from debug.
dtab 1
  map debug
;set the title to the 0th string (HelloWorld)
titl 0
;end the load processing. I forgot this once, and it thought that a variable I entered was an invalid string table reference O.o
end
; ==CODE SEGMENT== ;
;the Launch marker, used by the event table.
mark adr_launch
  ;push the 1st string (Hello, World!) onto the argstack to be used by console.print.
  pstr 1
  ;call console.print, which pops the above string off the stack and uses it.
  call console.print
;end queue saving. if you forget this, it might put click into tick or something bad like that.
end


this might still look scary. lets get rid of the comments.

Code:
stab 2
  str HelloWorld
  str Hello, World!
etab 1
  elnch adr_launch
dtab 1
  map debug
titl 0
end
mark adr_launch
  pstr 1
  call console.print
end


still scary? lets show the Cyscript that would make this when I get the Cyscript compiler done! XD

Code:
T HelloWorld
<Launch
  .Console.Print|Hello, World!
>


is that better? Razz

Hopefully, sheo will learn this really well and be the 2nd-best cycode coder on earth Very Happy
Back to top
View user's profile Send private message MSN Messenger
Super_Llama
Lead Scripter
Lead Scripter


Joined: 04 Jun 2007
Posts: 1503
Location: The Krypton Zoo

PostPosted: Wed Feb 11, 2009 7:32 pm    Post subject: Reply with quote

=new functions=
jump address - Jumps to a marked address in this script, this queue (does not cross queues or scripts, and neither does jeq)
buff address - Adds a handler to jump to address AFTER the entire queue has been executed. Good for something you only want done after all the other scripts are done.


NOTE:
Use endb as little as possible. This stops execution of the entire queue, including any scripts that come after. Some scripts may not be executed at all because of endb, and I'm changing all of the endb's in the above script to jump ends because I want it to be a sort of OS script that allows others to pass, and facilitates the process. If you want to just exit one script and leave the rest to execute, use a jump to the end of your script like this:

Code:
stab 3
 str Example
 str -before-
 str -after-
etab 1
 etick adr_tick
dtab 1
 map debug
titl 0
;you have to use an end here, and at the end of queues. it doesn't stop the execution but it stops queue saving.
end
mark adr_tick
 ;add the tick_continue address to the end of the queue.
 buff tick_continue
 ;print the 1st string, "-before-"
 pstr 1
 call console.print
 ;exit the before part; use jump
 jump tick_exit
  ;mark the part to come back to after the rest of the scripts.
  mark tick_continue
    ;print the 2nd string, "-after-"
    pstr 2
    call console.print
   ;don't need a jump exit since you're already there, but you need an endb so that it doesn't run any scripts after this one during the rerun.
   endb
 mark tick_exit
end


Now let's have another script to load afterward to demonstrate that its working.

Code:
stab 2
 str Example2
 str Middle!
etab 1
 ;notice I used the same name for the address. This doesn't matter, since when compiled these will be decomposed to a long value of the address. As long as I don't use the same name twice in one script, its fine.
 etick adr_tick
dtab 1
 map debug
titl 0
end
mark adr_tick
  ;print "Middle!"
  pstr 1
  call console.print
end


The above scripts, when loaded in the respective order, will spam:

-before-
Middle!
-after-

to the console.
=D
_________________

^go to my ORP forums^

92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.


Last edited by Super_Llama on Wed Feb 11, 2009 9:48 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Sheogorath
Admin (Post Whore)
Admin (Post Whore)


Joined: 05 Apr 2007
Posts: 1751
Location: Shivering Isles

PostPosted: Wed Feb 11, 2009 7:44 pm    Post subject: Reply with quote

Should the program be able to handle its own que saving lol?

Anyway, you did a great job super llama and I am willing(as soon as I get some time away from real life) to help you in any way that I can.
_________________



and he is always watching...
Back to top
View user's profile Send private message
Super_Llama
Lead Scripter
Lead Scripter


Joined: 04 Jun 2007
Posts: 1503
Location: The Krypton Zoo

PostPosted: Wed Feb 11, 2009 9:54 pm    Post subject: Reply with quote

Quote:

Should the program be able to handle its own que saving lol?


It does, you use the event table to point to each queue's beginning. it jumps there, and reads until it finds an end, then stops saving the queue. The script itself isn't ever executed; as soon as the queues are saved, the file is closed. But since all the code in the script is saved to one of the event queues, the program runs those instead (to avoid having to browse through all the current scripts; this way it can just do everything that its supposed to when it is supposed to.)

Next time we talk, I'll send you the updated Cytools, the Cycode prototype, and the Cylibs, and we'll see if you can write some cyasm Very Happy

After I get the compiler done (next on my list after variables), then we can use Cyscript instead of cyasm since the compiler translates Cyscript into cyasm. The assembler (which we already have) translates the cyasm into the bytecode, which is read by the Cycode Prototype, and eventually the game engine.
_________________

^go to my ORP forums^

92% of teens have moved on to rap. If you are part of the 8% who still listen to real music, copy and paste this into your signature.
Back to top
View user's profile Send private message MSN Messenger

Display posts from previous:   
Post new topic   Reply to topic    Visit the new forums Forum Index -> CyFyre development and implementation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Create your own free forum now!
Terms of Service Purchase Ad Removal Forum Archive Report Abuse