sd-8516_user_s_guide
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| sd-8516_user_s_guide [2026/02/20 20:49] – created appledog | sd-8516_user_s_guide [2026/02/21 10:20] (current) – appledog | ||
|---|---|---|---|
| Line 15: | Line 15: | ||
| Type this right now (press ENTER after the line): | Type this right now (press ENTER after the line): | ||
| - | | + | <codify BASIC> |
| + | ? "HELLO WORLD" | ||
| + | </ | ||
| The computer should immediately display: | The computer should immediately display: | ||
| Line 23: | Line 25: | ||
| Now try: | Now try: | ||
| - | | + | <codify BASIC> |
| + | ? 42 + 8 | ||
| + | </ | ||
| It prints 50. You can do math right away, no program needed. This is called **direct mode,** directly entering commands on the terminal. | It prints 50. You can do math right away, no program needed. This is called **direct mode,** directly entering commands on the terminal. | ||
| Line 34: | Line 38: | ||
| Now carefully type these lines (press ENTER after each one): | Now carefully type these lines (press ENTER after each one): | ||
| - | | + | <codify BASIC> |
| - | 20 GOTO 10 | + | 10 PRINT "HELLO WORLD" |
| + | 20 GOTO 10 | ||
| + | </ | ||
| Type **RUN** and press ENTER. | Type **RUN** and press ENTER. | ||
| Line 48: | Line 54: | ||
| You don't have to type lines in order, the computer will sort them for you automatically. Try this: | You don't have to type lines in order, the computer will sort them for you automatically. Try this: | ||
| - | | + | <codify BASIC> |
| - | 10 ? "BUT LINE 10 RUNS FIRST" | + | 20 ? "LINE 20 COMES FIRST ANYWAY!" |
| + | 10 ? "BUT LINE 10 RUNS FIRST" | ||
| + | </ | ||
| **RUN** | **RUN** | ||
| Line 67: | Line 75: | ||
| Try this in direct mode: | Try this in direct mode: | ||
| - | | + | <codify BASIC> |
| - | + | LET A = 25 | |
| - | ? A | + | |
| + | ? A | ||
| + | </ | ||
| It prints 25. | It prints 25. | ||
| Line 75: | Line 85: | ||
| Now a tiny counting program: | Now a tiny counting program: | ||
| - | | + | <codify BASIC> |
| - | 20 ? A | + | 10 LET A = 1 |
| - | 30 LET A = A + 1 | + | 20 ? A |
| - | 40 IF A <= 10 THEN GOTO 20 | + | 30 LET A = A + 1 |
| - | 50 ? "BLAST OFF!" | + | 40 IF A <= 10 THEN GOTO 20 |
| + | 50 ? "BLAST OFF!" | ||
| + | </ | ||
| **RUN** | **RUN** | ||
| Line 110: | Line 122: | ||
| Add these lines to make a simple checker: | Add these lines to make a simple checker: | ||
| - | | + | <codify BASIC> |
| - | 50 IF E <> 42 THEN ? "TRY AGAIN!" | + | 40 IF E = 42 THEN GOTO 70 |
| - | 60 GOTO 10 | + | 50 IF E <> 42 THEN ? "TRY AGAIN!" |
| - | 70 PRINT "YOU FOUND THE ANSWER!" | + | 60 GOTO 10 |
| + | 70 PRINT "YOU FOUND THE ANSWER!" | ||
| + | </ | ||
| **RUN** and try a guess until you hit 42. (42 is a reference to the Hitchhiker' | **RUN** and try a guess until you hit 42. (42 is a reference to the Hitchhiker' | ||
| Line 132: | Line 146: | ||
| 40 LET A = 1 | 40 LET A = 1 | ||
| 50 LET B = 100 | 50 LET B = 100 | ||
| - | + | 60 LET D = RAND( B - A + 1 ) + A - 1 : REM SECRET NUMBER! | |
| - | FIXME | + | 70 LET F = 0 |
| - | UNDER CONSTRUCTION | + | 80 LET F = F + 1 |
| - | + | 90 PRINT "" | |
| - | 60 D = RAND( B - A + 1 ) + A - 1 : REM SECRET NUMBER! | + | 100 PRINT " |
| - | 70 F=0 | + | 110 PRINT " |
| - | 80 F=F+1 | + | |
| - | 90 ? "" | + | |
| - | 100 ? " | + | |
| - | 110 ? " | + | |
| 120 INPUT "YOUR GUESS:"; | 120 INPUT "YOUR GUESS:"; | ||
| - | 130 IF E>B THEN ? "TOO LARGE!": | + | 130 IF E > B THEN PRINT "TOO LARGE!" |
| - | 140 IF E<A THEN ? "TOO SMALL!": | + | 140 IF E < A THEN PRINT "TOO SMALL!" |
| - | 150 IF E<D THEN ? " | + | 150 IF E < D THEN PRINT " |
| - | 160 IF E>D THEN ? " | + | 160 IF E > D THEN PRINT " |
| - | 170 ? "YOU GOT IT!" | + | 170 PRINT "YOU GOT IT!" |
| - | 180 ? " | + | 180 PRINT " |
| - | 190 ? "PLAY AGAIN? (Y/ | + | 190 PRINT "PLAY AGAIN? ( 1=Y / 0=N ) "; |
| - | 200 INPUT G$ | + | 200 INPUT G |
| - | 210 IF G$=" | + | 210 IF G = 1 THEN GOTO 50 |
| - | 220 ? "BYE FOR NOW!" | + | 220 PRINT "BYE FOR NOW!" |
| </ | </ | ||
| Line 159: | Line 169: | ||
| This is the spirit of 8-bit BASIC—type it in, play it, tweak it, make it yours. Just like the old days when you'd stay up late copying listings from magazines. | This is the spirit of 8-bit BASIC—type it in, play it, tweak it, make it yours. Just like the old days when you'd stay up late copying listings from magazines. | ||
| - | **What' | + | === IF-THEN EXAMPLE |
| - | + | ||
| - | You've got the basics: PRINT/?, variables, math (+ - * /), GOTO, IF-THEN, INPUT, and RAND(). For more power, check the **SD-8516 Programmer' | + | |
| - | + | ||
| - | Experiment! Change the messages, make the range bigger, add more hints. That's how so many great games started back in the day. | + | |
| - | + | ||
| - | Happy programming, | + | |
| - | + | ||
| - | + | ||
| - | == GOSUB | + | |
| - | Welcome back to Stellar BASIC on your SD-8516! We're building on the classic Tiny BASIC spirit from 1975; small, fast, and full of that pure home-computer magic. Type in a few lines, hit RUN, and watch your creation come to life! | + | |
| - | + | ||
| - | Stellar BASIC keeps things simple: integer math only, single-letter variables (A–Z), line-numbered programs, PRINT, INPUT, and IF. | + | |
| - | + | ||
| - | Here are some BASIC commands you can try right when you turn on your computer: | + | |
| - | + | ||
| - | PRINT "HELLO WORLD!" | + | |
| - | + | ||
| - | LET A = -5 ( This sets A to 5 ) | + | |
| - | PRINT A ( This will print 5 ) | + | |
| - | PRINT A*2 ( Prints 10 ) | + | |
| Here is an example program: | Here is an example program: | ||
| - | | + | <codify BASIC> |
| - | 20 PRINT A | + | 10 LET A = 5 |
| - | 30 LET A = A - 1 | + | 20 PRINT A |
| - | 40 IF A > 0 THEN GOTO 20 | + | 30 LET A = A - 1 |
| - | 50 PRINT " | + | 40 IF A > 0 THEN GOTO 20 |
| + | 50 PRINT " | ||
| + | </ | ||
| Next, type **RUN.** You will see a countdowns to 1, then " | Next, type **RUN.** You will see a countdowns to 1, then " | ||
| Line 198: | Line 189: | ||
| Here is an example of a GOSUB helper function: | Here is an example of a GOSUB helper function: | ||
| - | | + | <codify BASIC> |
| - | 20 LET A = 2 | + | 10 REM GOSUB SQUARE DEMO |
| - | 30 GOSUB 1000 | + | 20 LET A = 2 |
| - | 40 LET A = 3 | + | 30 GOSUB 1000 |
| - | 50 GOSUB 1000 | + | 40 LET A = 3 |
| - | 60 LET A = 4 | + | 50 GOSUB 1000 |
| - | 70 GOSUB 1000 | + | 60 LET A = 4 |
| - | 80 LET A = 5 | + | 70 GOSUB 1000 |
| - | 90 GOSUB 1000 | + | 80 LET A = 5 |
| - | 100 GOTO 9000 | + | 90 GOSUB 1000 |
| - | 9000 REM END | + | 100 GOTO 9000 |
| + | 9000 REM END | ||
| - | | + | 1000 REM THIS HELPER FUNCTION WILL PRINT THE SQUARE OF A |
| - | 1010 PRINT A * A | + | 1010 PRINT A * A |
| - | 1020 RETURN | + | 1020 RETURN |
| + | </ | ||
| After you enter this program and type RUN, you will see the result 4, 9, 16, 25. As you can see, every time the program calls **GOSUB 1000,*** it runs the code at LINE NO 1000 and then **RETURN**s to continue in the main program. | After you enter this program and type RUN, you will see the result 4, 9, 16, 25. As you can see, every time the program calls **GOSUB 1000,*** it runs the code at LINE NO 1000 and then **RETURN**s to continue in the main program. | ||
| Line 224: | Line 217: | ||
| **NEW** then type: | **NEW** then type: | ||
| - | 10 ? "" | + | <codify BASIC> |
| + | 10 PRINT "" | ||
| 20 GOSUB 900 : REM SHOW INSTRUCTIONS | 20 GOSUB 900 : REM SHOW INSTRUCTIONS | ||
| 30 A=1 : B=100 | 30 A=1 : B=100 | ||
| Line 242: | Line 236: | ||
| 150 GOSUB 400 | 150 GOSUB 400 | ||
| 160 ? " | 160 ? " | ||
| - | 170 ? "PLAY AGAIN? (Y/ | + | 170 ? "PLAY AGAIN? (Y=1/N-0)" |
| - | 180 INPUT G$ | + | 180 INPUT G |
| - | 190 IF G$=" | + | 190 IF G = 1 THEN GOTO 30 |
| 200 ? " | 200 ? " | ||
| - | 210 END | + | 210 GOTO 5000 |
| 400 ? "YOU GOT IT IN"; | 400 ? "YOU GOT IT IN"; | ||
| Line 268: | Line 262: | ||
| 930 ? " | 930 ? " | ||
| 940 RETURN | 940 RETURN | ||
| + | 5000 REM END | ||
| + | </ | ||
| - | **RUN** | + | Try to **RUN** |
| **Negative Numbers in Action** | **Negative Numbers in Action** | ||
| Line 275: | Line 271: | ||
| Since negatives are fully supported, try tweaking the game or make a countdown timer: | Since negatives are fully supported, try tweaking the game or make a countdown timer: | ||
| - | 10 ? " | + | <codify BASIC> |
| - | 20 A=0 | + | 10 PRINT " |
| - | 30 ? A | + | 20 LET A = 0 |
| - | 40 A=A-1 | + | 30 PRINT A |
| - | 50 IF A>=-10 THEN GOTO 30 | + | 40 LET A = A - 1 |
| - | 60 ? "BLAST OFF INTO NEGATIVE SPACE!" | + | 50 IF A >= - 10 THEN GOTO 30 |
| + | 60 PRINT "BLAST OFF INTO NEGATIVE SPACE!" | ||
| + | </ | ||
| - | **What's Next?** | + | === WHILE, DO-WHILE, and FOR-NEXT Part I |
| + | Stellar BASIC V1 keeps things simple and fast; no built-in FOR-NEXT or WHILE (yet! --they're coming in future updates). But you can create powerful repeating loops using just IF...THEN and GOTO, plus a counter variable when needed. This section will demonstrate the kind of clever thinking you will need to write advanced programs in TinyBASIC. | ||
| - | You've now got the core toolkit: ?, variables | + | The key tricks: |
| + | |||
| + | * WHILE -- A while loop checks the condition first, so place the IF check before the loop body. | ||
| + | * DO-WHILE -- A do loop runs at least once, so place the IF check at the end of the loop body. | ||
| + | * FOR-NEXT -- A for-next is essentially a WHILE loop (see below). | ||
| + | |||
| + | Let's see these in action with short examples you can type in right now. | ||
| + | |||
| + | ==== WHILE | ||
| + | WHILE is short for WHILE-DO. The loop check is at the front of the do-loop (so it may skip the loop entirely). This is like "while something is true, keep doing the body." | ||
| + | |||
| + | Example: Print numbers from 1 to 5, checking first. | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 LET I = 1 | ||
| + | 20 IF I > 5 THEN GOTO 60 | ||
| + | 30 ? I | ||
| + | 40 LET I = I + 1 | ||
| + | 50 GOTO 20 | ||
| + | 60 ? " | ||
| + | </ | ||
| + | |||
| + | This prints 1 through 5. If you change line 10 to LET I=10, it skips the printing entirely, since the condition was false when we checked the loop condition | ||
| + | |||
| + | ==== DO-WHILE | ||
| + | In this style the do-loop is executed and then if the condition (the while) passes, it executes the loop again. This style of loop always runs at least once. | ||
| + | |||
| + | Example: Keep asking for a positive number until you get one. | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 INPUT "ENTER A POSITIVE NUMBER ", N | ||
| + | 20 IF N > 0 THEN GOTO 40 | ||
| + | 30 PRINT "TRY AGAIN – MUST BE POSITIVE!" | ||
| + | 40 IF N <= 0 THEN GOTO 10 | ||
| + | 50 PRINT " | ||
| + | </ | ||
| + | |||
| + | This program runs the INPUT at least once. If you enter -5, it complains and loops back. If positive, it exits. The check is at the bottom; no skip on first pass. | ||
| + | |||
| + | ==== FOR-NEXT | ||
| + | Here, the FOR idea is to iterate over a range, and the NEXT check usually occurrs at the front of the loop (but may also occurr at the end of the loop). | ||
| + | |||
| + | Example: Countdown from 10 to 0, check at top. | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 LET C = 10 | ||
| + | 20 IF C >= 0 THEN GOTO 40 | ||
| + | 30 GOTO 70 | ||
| + | 40 PRINT C | ||
| + | 50 LET C = C - 1 | ||
| + | 60 GOTO 20 | ||
| + | 70 PRINT " | ||
| + | </ | ||
| + | |||
| + | Observe that sometimes flipping the logic of the test makes the code cleaner (no extra check): | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 LET C = 10 | ||
| + | 20 IF C < 0 THEN GOTO 60 | ||
| + | 40 PRINT C | ||
| + | 50 LET C = C - 1 | ||
| + | 60 GOTO 20 | ||
| + | 70 PRINT " | ||
| + | </ | ||
| + | |||
| + | In this second case, inverting the logic falls-through to the do-loop. This is more efficient, even though | ||
| + | |||
| + | ==== FOR-NEXT part II | ||
| + | Here is another example of a similar loop, that amounts to a FOR-NEXT loop. | ||
| + | |||
| + | Example: Print even numbers 2 to 20 (step +2). | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 LET X = 2 | ||
| + | 20 IF X > 20 THEN GOTO 60 | ||
| + | 30 PRINT X | ||
| + | 40 LET X = X + 2 | ||
| + | 50 GOTO 20 | ||
| + | 60 PRINT "EVEN NUMBERS DONE!" | ||
| + | </ | ||
| + | |||
| + | Or, to simulate STEP -1 (countdown), | ||
| + | |||
| + | <codify BASIC> | ||
| + | 10 LET Y = 20 | ||
| + | 20 IF Y < 1 THEN GOTO 60 | ||
| + | 30 PRINT Y | ||
| + | 40 LET Y = Y - 1 | ||
| + | 50 GOTO 20 | ||
| + | 60 PRINT "BLAST OFF!" | ||
| + | </ | ||
| + | |||
| + | These methods of program flow control are from old-school TinyBASIC programming. This was the norm -- inventive uses of code. There is a LOT you can do with TinyBASIC. It's understandable, | ||
| + | |||
| + | === An Exercise | ||
| + | |||
| + | You can practice your BASIC skills with these exercises: | ||
| + | |||
| + | * Make the WHILE example count backwards. | ||
| + | * Turn the guessing game's round counter into a DO-style loop (run at least one round?). | ||
| + | * Add a "Play again?" | ||
| + | |||
| + | When FOR-NEXT arrives in a future update, you'll appreciate how these hand-built loops taught you control flow. Until then, don't forget to "think differently!" | ||
| + | |||
| + | == NEXT STEPS | ||
| + | **What' | ||
| - | Check the **SD-8516 Programmer's Reference Guide** for deeper details: upcoming FOR-NEXT loops, PEEK/POKE for peeking at memory (classic retro fun), string variables | + | You've now got the core toolkit: PRINT, LET variables, INPUT, IF-THEN, GOTO, RAND(), and GOSUB/ |
| - | Keep typing, keep tweaking. That's how the best 8-bit adventures were born. You' | + | You are in the driver' |
| - | --- | + | //Check the **SD-8516 Programmer' |
| - | This update feels natural and progressive: | ||
sd-8516_user_s_guide.1771620544.txt.gz · Last modified: by appledog
