📄 buffinfo.doc
字号:
-1Unprotect Protected BASIC Programs Easily-0
And now, on to a couple of useful examples. You will find
BUFFUNPR.BAS in listing 2. This is a practical program which
allows you to unprotect a protected BASIC program by simply giving
the name of the file. Protected BASIC programs are those saved
using SAVE "FILENAME.EXT", P. Although you can execute these
programs, statements such as POKE, PEEK, LIST, LLIST, and SAVE are
disabled. The techniques necessary to unprotect BASIC programs
have been published in at least a dozen places, and they are
listed in figure 4. I have used these techniques on several
occasions, but I wanted a way to automate the process.
BUFFUNPR.BAS is able to do that by using the keyboard buffer
loading techniques we have covered.
-1BUFFUNPR.BAS May Save Itself-0
The program uses itself to BSAVE the protection status byte.
Therefore, BUFFUNPR.BAS must be unprotected or it will not work.
BUFFUNPR.BAS checks its own status byte, and if it is protected,
it unprotects itself and saves an unprotected version of itself.
This technique would be of use to anyone experimenting with
protected programs. If a program always unprotects itself when it
runs, there is little chance of accidently protecting a program.
I accidently protected the first version of BUFFUNPR.BAS, and had
to unprotect it with the labor intensive method. A program can
unprotect itself because PEEK and POKE are not disabled within a
protected program. These statements are only disabled in direct
mode when a protected program is loaded.
-1Popalarm Setup-0
If you have Popalarm, you probably like it with one complaint.
You always have to set it up the way you like every time you
install it, including moving the display to your preferred corner,
setting display options, etc. POPCMDS.BAS is a short BASIC
program that uses BUFFLOAD.SUB to load the keyboard buffer with
the installation commands I prefer. These commands moves the
display to the upper-right corner, sets the time to display each
minute, and the alarm to chime each hour.
To use it, just include the statement BASIC POPCMDS in your
batch file following the POPALARM command. If you prefer a
different installation, you must change the program, but that
should not be tough with all you have learned.
Page 9
By Jim Pottkotter, 05/20/85
-1A Final Demo-0
BUFFDEMO.BAS is in listing 3. This program demonstrates the
execution of statements from within a program that normally leave
you in direct mode. However, by using the BUFFLOAD.BAS routine,
control is returned to the program. If you have followed along
this far, there are a couple of neat tricks in the program, but no
big surprises. You get a menu to select the desired
demonstration. The following statements are demonstrated.
LIST some lines and return to the menu.
STOP the program and return to the menu.
END the program and return to the menu.
RENUM some lines and return to the menu.
DELETE some lines and return to the menu.
Exit to DOS and execute a "DIR *.BAS".
-1Real Trivia-0
In DOS 2.X BASIC the <CTRL> <PRTSC> combination affects the
buffer differently than other keystrokes. In DOS 2.X, this
combination works in BASIC like it did under DOS in versions
earlier than 2.X; it logs all displayed text to the printer. How
it affects the buffer is a little bit of a surprise.
The following senario assumes you do not currently have this
function invoked. If the buffer is empty, and you press <CTRL>
<PRTSC>, the function is invoked, and any following screen output
is logged to the printer. However, even though the code is placed
in the buffer, it is acted on immediately, unlike other codes
which are queued. The code is not queued in the buffer. Strange
indeed.
If you then enter this same combination again, the function is
toggled off, but the code is queued. If you continue to enter
this combination, the buffer is alternately cleared and loaded
with one code. Entering any other keystroke that is normally
queued, followed with several entries of the <CTRL> <PRTSC>
combination, results in all of the entries being queued.
Apparently, the buffer handling ROM code checks to see if the
first active character code in the buffer is from <CTRL> <PRTSC>.
If it is, the log function is toggled on, and the the code is
removed from the head of the active buffer entries.
Page 10
By Jim Pottkotter, 05/20/85
-1Addresses of the Buffer Management Area-0
Decimal Address
Relative to
Segment Zero Contents
1050 Contains the decimal offset from 1024
into buffer indicating where the
first active character is located.
1052 Contains the decimal offset from 1024
into buffer indicating where the next
active character will be inserted.
1054 - 1084 Keyboard buffer.
Figure 1.
-1Statements Which Exit to Direct Mode-0
Initializes Closes
Statement Variables Files
LIST NO NO
MERGE YES YES
DELETE YES YES
RENUM NO NO
STOP NO NO
END NO YES
SYSTEM YES YES
(Exits to DOS)
RUN YES MAYBE
CHAIN MAYBE NO
Figure 3.
Page 11
By Jim Pottkotter, 05/20/85
-1Steps to Unprotect a Protected BASIC Program-0
1. LOAD an unprotected program.
2. Enter DEF SEG to set segement to default.
3. BSAVE one byte from memory location 1124 to
a file using BSAVE"FILENAME.EXT",1124,1.
Location 1124 contains an ASCII 0 when an
unprotected program is loaded, and an ASCII
254 when a protected program is loaded.
4. LOAD the protected program.
5. BLOAD the status byte to unprotect the program
using BLOAD"FILENAME.EXT". This step overlays
the protection status byte in the protected
program, enabling statements such as POKE,
SAVE, and LIST.
6. SAVE the now unprotected version of the
program.
Figure 4.
-1Related Information in the 2.00 BASIC Reference Manual-0
Subject Page
Direct vs. indirect mode 2-7
Automatic typing using <ALT> <letter> 2-14
Generating codes with <CTRL> key 2-15
INKEY$ handling of extended codes 4-119
Soft key programming with KEY 4-131
ASCII character codes G-1
Extended character codes G-7
Keyboard scan codes K-1
Figure 5.
Page 12
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -