Tricks in BASIC
Re: Tricks in BASIC
Ahh.. PI and "NOT PI".. that's the way to optimize!
The Spectrum has also "BIN" meaning zero as well, but it adds the whole mantissa, thus it is equivalent to '0'. Yet NOT PI is the only choice
The Spectrum has also "BIN" meaning zero as well, but it adds the whole mantissa, thus it is equivalent to '0'. Yet NOT PI is the only choice
-
- Posts: 3
- Joined: Sun Aug 18, 2019 4:34 pm
Re: Tricks in BASIC
It's possible to squeeze the maze generator into just one line using some USR calls in a PRINT statement like this:
Code: Select all
10 PRINT "@80@00@01@02@87@04@05@83@03@85@81@82@07@84@06@86"(RND*15+NOT PEEK USR (3085+(ABS(PEEK 16441-17)=16))*USR 3663)
USR 3086 does SCROLL, which is triggered when 16441 (S_POSN_X) = 33 (at start of program) or 1 (when about to run out of screen space)
USR 3663 is used to GOTO 0
Enjoy!
Re: Tricks in BASIC
How the %$^%#%$@^%#$@ do you type that in? How do you type an @?AyreGuitar wrote: ↑Wed Sep 22, 2021 8:06 pmIt's possible to squeeze the maze generator into just one line using some USR calls in a PRINT statement like this:USR 3085 does nothing, just returns, but...Code: Select all
10 PRINT "@80@00@01@02@87@04@05@83@03@85@81@82@07@84@06@86"(RND*15+NOT PEEK USR (3085+(ABS(PEEK 16441-17)=16))*USR 3663)
USR 3086 does SCROLL, which is triggered when 16441 (S_POSN_X) = 33 (at start of program) or 1 (when about to run out of screen space)
USR 3663 is used to GOTO 0
Enjoy!
-
- Posts: 3
- Joined: Sun Aug 18, 2019 4:34 pm
Re: Tricks in BASIC
Sorry, I was using the same convention I'd seen on this thread for using hexadecimal numbers for graphics characters, so "@80" is CHR$(128)
Here's a screenshot running on JSZeddy emulator for the actual listing: The graphics string is the same as the original multi line version earlier in this thread.
Here's a screenshot running on JSZeddy emulator for the actual listing: The graphics string is the same as the original multi line version earlier in this thread.
Re: Tricks in BASIC
Code: Select all
10 GOTO 10-8*(INKEY$="N")
Code: Select all
10 IF INKEY$<>"N" THEN GOTO 10
11 GOTO 2
Re: Tricks in BASIC
Send datas from Basic to an ASM routine: (from Greg's AY sound driver)
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Re: Tricks in BASIC
Retrieve the "BC", "B" and "C" value in BASIC from an USR function:
Code: Select all
1 REM [ASM= \
ORG 16514|\
LD BC,$0100|\
INC BC|\
INC BC|\
RET|\
]
10 PRINT AT 1,1;"BC= ";USR 16514
15 REM COMPUTE THE VALUE
20 LET R=USR 16514
30 LET B= INT (R/256)
40 LET C= R-(B*256)
50 PRINT AT 3,1;"B= ";B,"C= ";C
55 REM OR...
60 RAND USR 16514
70 PRINT AT 5,1;"BC= ";PEEK 16435*256+PEEK 16434
80 PRINT AT 7,1;"B= ";PEEK 16435,"C= ";PEEK 16434
Xavier ...on the Facebook groupe : "Zx81 France"(fr)