home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
forth
/
compiler
/
fpc
/
tutor
/
l7p040
< prev
next >
Wrap
Text File
|
1990-07-15
|
4KB
|
97 lines
╔════════════════════════════════════════════════════╗
║ Lesson 7 Part 044 F-PC 3.5 Tutorial by Jack Brown ║
╚════════════════════════════════════════════════════╝
┌────────────────────────────────────────┐
│ Demonstration of Vocabulary Word Set │
└────────────────────────────────────────┘
ORDER <enter> \ See also status display top right.
Context: FORTH FORTH ROOT <--- Default search path
Current: FORTH ok <--- Default defining vocabulary
ONLY ORDER <enter> \ Clear vocabulary search order
Context: ROOT ROOT \ See the status display top right.
Current: FORTH ok
DEFINITIONS ORDER <enter> \ Make defining or CURRENT vocabulary
Context: ROOT ROOT \ the first vocabulary in the CONTEXT
Current: ROOT \ search path.
FORTH ORDER <enter> \ Place FORTH in the search path.
Context: FORTH ROOT
Current: ROOT ok
ALSO ORDER <enter> \ See the status display.
Context: FORTH FORTH ROOT \ ALSO is like DUP in that two copies
Current: ROOT ok \ of FORTH are in the search path.
DEFINITIONS ORDER <enter> \ Make FORTH the CURRENT vocabulary
Context: FORTH FORTH ROOT \ This is how F-PC is initialized.
Current: FORTH ok
The following sequence will restore F-PCs default start up search order.
ONLY FORTH DEFINITIONS ALSO
┌───────────────────────────────────────┐
│ Creating and Using New Vocabularies │
└───────────────────────────────────────┘
VOCABULARY SOUND <enter> ok \ Make a new vocabulary
VOCS <enter> \ See our new vocabulary
SOUND EDITOR BUG HIDDEN ROOT USER ASSEMBLER FILES FORTH ok
\ Place duplicate copy of the SOUND vocabulary in the ROOT directory
\ so that it can be found when the FORTH directory is not in the
\ search path.
ROOT DEFINITIONS <enter> ok \ Place an extra copy in ROOT
: SOUND SOUND ; \ vocabulary.
SOUND isn't unique ok
WORDS <enter> \ see ROOT words displayed.
\ Get ready to add some new word definitions to the SOUND vocabulary.
SOUND DEFINITIONS ORDER <enter>
Context: SOUND FORTH ROOT
Current: SOUND ok
\ New words to fetch and store to 8 bit I/O ports.
\ PC! ( byte n -- ) Output byte to port number n.
\ PC@ ( n byte ) Input byte from port number n.
HEX
: S.ON ( -- ) \ Turn speaker on.
61 PC@ 3 OR 61 PC! ;
: S.OFF ( -- ) \ Turn speaker off.
61 PC@ FFFC AND 61 PC! ;
DECIMAL
: TONE ( freq -- ) \ Make tone of specified frequency.
21 MAX \ Lowest frequency.
1.190000 ROT \ Get divisor for timer.
MU/MOD \ 16bit.rem 32bit.quot
DROP NIP \ Keep 16-bit quotient only.
[ HEX ] \ Want HEX radix base for following.
0B6 043 PC! \ Write to timer mode register.
100 /MOD SWAP \ Split into hi and low byte.
42 PC! 42 PC! \ Store low and high byte in timer.
S.ON ; \ turn speaker on.
DECIMAL
\ Define some notes.
: C ( -- ) 131 TONE ; : D ( -- ) 147 TONE ;
: E ( -- ) 165 TONE ; : F ( -- ) 175 TONE ;
: G ( -- ) 196 TONE ; : A ( -- ) 220 TONE ;
: B ( -- ) 247 TONE ; : CC ( -- ) 262 TONE ;
\ Delay for one beat time period.
: BEAT ( -- ) 1 SECONDS ( 20000 0 DO LOOP ) ;
: SCALE ( -- ) \ Play the musical scale.
C BEAT D BEAT E BEAT F BEAT G BEAT
A BEAT B BEAT CC BEAT BEAT BEAT S.OFF ;
┌───────────────────────────────────┐
│ Please Move to Lesson 7 Part 050 │
└───────────────────────────────────┘