Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
im using the latest beta build
here is my source:
Code: BORDER 7 : PAPER 7 : INK 0 : CLS
PRINT AT 3,13 ; PAPER 1 ; INK 7 ; "BattleField"
PRINT AT 5,9 ; PAPER 7 ; INK 0 ; "Q - Up"
PRINT AT 6,9 ; PAPER 7 ; INK 0 ; "A - Down"
PRINT AT 7,9 ; PAPER 7 ; INK 0 ; "O - Left"
PRINT AT 8,9 ; PAPER 7 ; INK 0 ; "P - Right"
PRINT AT 9,9 ; PAPER 7 ; INK 0 ; "M - Select"
PRINT AT 10,3 ; PAPER 7 ; INK 0 ; "You have to select units"
PRINT AT 11,3 ; PAPER 7 ; INK 0 ; "to fight the enemy units"
PRINT AT 15,3 ; PAPER 7 ; INK 0 ; "Press any key to start"
60 LET j$ = INKEY$
IF j$ = "" THEN GOTO 60: END IF
cls
Dim BlueFactoryX (6) as uByte
Dim BlueFactoryY (6) as uByte
for x =1 to 6
BlueFactoryX(x) = byterndrange(1,30)
BlueFactoryY(x) = byterndrange(1,30)
next
drawFactories()
function drawFactories()
for x =1 to 6
print at BlueFactoryX(x), BlueFactoryY(x); "O"
next
end function
Function byterndrange (first As uByte, last As uByte) As uByte
return Rnd * (last - first) + first
End Function
here is the error message when I compile:
Quote:Traceback (most recent call last):
File "zxb.py", line 309, in <module>
File "zxb.py", line 242, in main
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1202, in traverse
File "zxbtrad.pyc", line 217, in emmit_let_left_part
TypeError: bad operand type for unary -: 'NoneType'
also it seems that underscores are not allowed in function names, is this right?
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
slenkar Wrote:im using the latest beta build
here is my source:
Code: BORDER 7 : PAPER 7 : INK 0 : CLS
PRINT AT 3,13 ; PAPER 1 ; INK 7 ; "BattleField"
PRINT AT 5,9 ; PAPER 7 ; INK 0 ; "Q - Up"
PRINT AT 6,9 ; PAPER 7 ; INK 0 ; "A - Down"
PRINT AT 7,9 ; PAPER 7 ; INK 0 ; "O - Left"
PRINT AT 8,9 ; PAPER 7 ; INK 0 ; "P - Right"
PRINT AT 9,9 ; PAPER 7 ; INK 0 ; "M - Select"
PRINT AT 10,3 ; PAPER 7 ; INK 0 ; "You have to select units"
PRINT AT 11,3 ; PAPER 7 ; INK 0 ; "to fight the enemy units"
PRINT AT 15,3 ; PAPER 7 ; INK 0 ; "Press any key to start"
60 LET j$ = INKEY$
IF j$ = "" THEN GOTO 60: END IF
cls
Dim BlueFactoryX (6) as uByte
Dim BlueFactoryY (6) as uByte
for x =1 to 6
BlueFactoryX(x) = byterndrange(1,30)
BlueFactoryY(x) = byterndrange(1,30)
next
drawFactories()
function drawFactories()
for x =1 to 6
print at BlueFactoryX(x), BlueFactoryY(x); "O"
next
end function
Function byterndrange (first As uByte, last As uByte) As uByte
return Rnd * (last - first) + first
End Function
here is the error message when I compile:
Quote:Traceback (most recent call last):
File "zxb.py", line 309, in <module>
File "zxb.py", line 242, in main
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1202, in traverse
File "zxbtrad.pyc", line 217, in emmit_let_left_part
TypeError: bad operand type for unary -: 'NoneType' Ok. Regardless your code, this is a compiler error. Thanks! :wink: Will fix it as soon as possible :!:
slenkar Wrote:also it seems that underscores are not allowed in function names, is this right? Not yet (the assembler does, though). I'm thinking to allow them. What do you think? (other people has asked for it).
It's a bit hard, because I used the "_" character as a namespace mangler. If the user declares "__PRINT", it can collide with the __PRINT subroutine in the /library-asm/ directory, and so on.
Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
I like underscores ![Smile Smile](https://www.boriel.com/forum/images/smilies/smile.png) if its possible I would like them , but if its too difficult I could go without.
Could you use any of these symbols as a name space mangler ?
-
?
|
Im glad you put functions in zxbasic and removed the need for line numbers
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
slenkar Wrote:I like underscores if its possible I would like them , but if its too difficult I could go without.
Could you use any of these symbols as a name space mangler ?
-
?
| Unfortunately not. In fact, the assembler allows ".". Thus this.identifier.is.a.valid.one is a valid identifier, and you can type:
Code: asm
ld a, a.very.large.identifier
end asm
This is 'cause in the near future, the dot will be used as a namespace separator. When this is done, then all ZXBasic stuff (variable names, etc...) will be prefixed with zxb.<id>, so the declared user variable could be "mangled" as zxb.var._a, and underscore variables, like _my_var will be mangled as zxb.var.__my_var and underscore could be allowed in variable names.
slenkar Wrote:Im glad you put functions in zxbasic and removed the need for line numbers ![Big Grin Big Grin](https://www.boriel.com/forum/images/smilies/biggrin.png) There are some libraries already done. Look in /library/. Just include them with #include <....bas> (use agle brackets for standard libraries, instead of quotes).
When using compiler optimization >= 1 (-O1, -O2, -O3...) unused functions won't be compiled to save memory. This will issue a warning you can safely ignore.
Allowing multiline sentences is what makes impossible to allow "single lined" IFs like in the original ZX BASIC, so every IF must be closed with its corresponding END IF.
READ, DATA & RESTORE not only are affected by this. They're really tricky.
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
slenkar Wrote:here is the error message when I compile:
Quote:Traceback (most recent call last):
File "zxb.py", line 309, in <module>
File "zxb.py", line 242, in main
File "zxbtrad.pyc", line 316, in traverse
File "zxbtrad.pyc", line 1202, in traverse
File "zxbtrad.pyc", line 217, in emmit_let_left_part
TypeError: bad operand type for unary -: 'NoneType' Okay, this bug seems to be fixed. Can you download v1.2.7-r2075 from the download page and test it, please?? :roll:
Also, remember INCBIN is not a preprocessor directive, but an assembler one (so no preceding # -sharp- character).
Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
works perfectly now, thanks :o
do you have a list of arguments that 'print' accepts?
the wiki page for 'print' hasnt been done yet
check out my game!
<!-- m --><a class="postlink" href="http://www.mediafire.com/?71xtf8habqbcgdy">http://www.mediafire.com/?71xtf8habqbcgdy</a><!-- m -->
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
slenkar Wrote:works perfectly now, thanks :o
do you have a list of arguments that 'print' accepts?
the wiki page for 'print' hasnt been done yet Ok, if you happen to use ZX Spectrum BASIC, PRINT works exactly as original PRINT except it's a different faster routine (not the one in the ROM, which is slower). It accepts AT, INK, PAPER, INVERSE, FLASH, BRIGHT, and OVER. Note INK 8 and PAPER 8 also work as expected. And unlike in ZX Basic, everything also affects PLOT,DRAW & CIRCLE routines.
OVER is extended as follows: - OVER 0: Print "as is", overwriting screen background
- OVER 1: Print XORing with screen background (as original ZX Spectrum)
- OVER 2: Print ORing with screen background
- OVER 3: Print ANDing with screen background
Using 2 & 3 you can achive a "filmation" effect (Alien 8, knight lore, etc...), by PRINTing OVER 3 the UDG mask, and then PRINTing OVER 2 the UDG.
TAB and , (the COMMA) work as in the original PRINT. The End Of Line character (') must be replaced with CHR$(13), because ZX Basic uses ' as an alias of REM
Also there are BOLD and ITALIC.
Try:
Code: PRINT BOLD 1; "HELLO "; BOLD 0; ITALIC 1; "WORLD"
If something does not work as expected here, please report (it might be a bug).
slenkar Wrote:check out my game!
<!-- m --><a class="postlink" href="http://www.mediafire.com/?71xtf8habqbcgdy">http://www.mediafire.com/?71xtf8habqbcgdy</a><!-- m --> I tried, but when clicked a download, it shows an HTTP error??? Try uploading in this post? Can you? (I can give you permission if not).
Update:Ok, just downloaded! (not sure what happened before!). Hey! This looks promising! :-)
Posts: 1,763
Threads: 55
Joined: Aug 2019
Reputation:
24
Okay, I've updated the compiler (go to download page, please), to ver 1.2.7-r2077. This version adds compatibility with Sinclair BASIC BIN syntax. So BIN 0101010, for example, should be allowed now.
Can you check it? :roll:
Posts: 282
Threads: 48
Joined: Feb 2011
Reputation:
0
thanks ill have to experiment with the OVER functions..
|