basic/doc/
appendix_a.rs

1/*!
2# Conversions and Compatibility
3
464K BASIC aims for compatibility with a time when BASIC usually came on ROM.
5There was an attempt to standardize BASIC in 1978 but it wouldn't succeed
6until ten years later. The lack of an accepted standard and the challenge
7of upgrading created many dialects of BASIC.
8
9There's a lot of programs which will run without modification because
1064K BASIC has all the quirks of the most popular ROM BASICs. This appendix
11covers the most common problems you may come across when running an old
12program. Mostly, there were multiple ways to do the same things. 64 BASIC
13always implements the method that uses the least keywords.
14
15## RANDOMIZE X
16Old computers often didn't have useful entropy, not even a real-time clock.
17Many implementations would reset the random number generator to the same state
18on ever run, but almost all would reset to the same state every boot.
19`RANDOMIZE` was used to get around this by asking the user for a seed.
2064K BASIC reseeds the random number generator with good entropy on every run,
21so in most cases you simply delete the unneeded code.
22
23`RANDOMIZE` without an X will prompt the user for a seed value.
24This allowed someone to replay the same game if they wanted.
25To emulate this behavior, here's a replacement.
26
27```text
28INPUT "Random Number Seed";A:RND=RND(-ABS(A))
29```
30
31Probably the most common way to seed the random number generator is to time
32how long it takes the user to respond to a prompt. This is not necessary
33in 64K BASIC so if you see something similar to the following, you can
34delete it.
35
36```text
37PRINT "Press any key to continue":WHILE INKEY$="":RND=RND():WEND
38```
39
40## GET A$
41
42To get a single keypress and store it in A$, 64K BASIC uses the newer style:
43```text
44A$ = INKEY$
45```
46
47## Integer BASIC
48Some versions of BASIC didn't support floating point types. Use `DEFINT`
49to change the default variable type to integer. The RND function needed
50to work without floats so we'll `DEF FN` a new one. Replace every `RND`
51with `FNRND`.
52```text
5310 DEFINT A-Z:DEF FNRND(X)=INT(RND()*X+1)
54```
55
56## LOCATE ROW,COL
57
58This is probably a GW-BASIC program so it might use graphics and sound.
59However, in many cases it is simply used to center text on the screen.
60Use `STRING$` to get a bunch of newlines and `SPC(X)` to move to the column.
61```text
62REM CLS:LOCATE 5,20:PRINT "TITLE"
63CLS:PRINT STRING$(5,10)SPC(20)"TITLE"
64```
65
66## KEY OFF/ON
67
68This controls display of the status line in GW-BASIC. Usually a program turns
69it off at the start and back on at the end. You can delete these.
70
71## SOUND and BEEP
72
7364K BASIC does not support sound. Your terminal might beep with:
74```text
75PRINT CHR$(7)
76```
77
78## OPTION BASE
79
80This selects if arrays start at 0 or 1. This isn't needed since memory isn't scarce.
81Also, 64K BASIC arrays are sparse so by simply not using 0 it won't be allocated.
82
83*/