| nedoPC project | nedoPC group | nedoPC forums |

Sprinter SDK Documentation


[PREV] : LESSON 3 : [NEXT]

Now we learn to use macros and libraries in RW1 programming language. Macros saved to files with extention RWI (if you remember source file with description of tiles list was file of macros). Libraries saved to files with extention RWL. Main difference between RWI and RWL is the rule to include RWI before function main(), but RWL after function main():
 robot "Hello" 
 author "NedoPC" 
 +inc/rw1_std.rwi
 +inc/rw1p2.rwi
 +hellos.rwi
 main() 
 { 
  termclear(@MYSPR) // fill screen
  say "HELLO, WORLD !" // hello world
  select 0 0 // choose cell to draw
  set @MYSPR // draw our picture
  loop: goto loop
 } 
 +lib/p2term.rwl
Here we included two files of macros (third inclusion is file of tiles identifiers). First one is standard macros of RW1 programming language inc/rw1_std.rwi and additional macros inc/rw1p2.rwi. And we included library for working with terminal lib/p2term.rwl. Now we may use function "termclear" to clear screen by defined tile. Note last line of function main(). It is code to loop command pointer in this line forever.

Let's add new tile to our list of tiles. To do this we have to open file hellos.spr (use F3 and change type of file to *.*) and put new definition:

 ;8x8-2/16
 BLUE   DB  #00,#00,#00,#00,#00,#00,#00,#00,#01 ;
 MYSPR  DB  #FF,#81,#A5,#81,#81,#9F,#81,#FF,#40 ;@
Again open hello.rw1 and run it to rebuild the project by system for use modified hellos.spr and than change our program to clear terminal by new tile:
 robot "Hello" 
 author "NedoPC" 
 +inc/rw1_std.rwi
 +inc/rw1p2.rwi
 +hellos.rwi
 main() 
 { 
  termclear(@BLUE) // fill screen
  termsetsay(2,0,#1E) // yellow on blue
  say "HELLO, WORLD !"  // hello world
  select 0 0 // choose cell to draw
  set @MYSPR // draw our picture
  loop: goto loop
 } 
 +lib/p2term.rwl
See, we add code to locate output position for text and set new color for it. Try it now! ;)

[ ONLINE HELP ]


Rambler's Top100
^ Go Up
©2002-2010 nedoPC.org