FE3 User Guide
FE3 User Guide
Guide
Version 1.8
Final Expansion 3 User Guide
Copyright Information
Version Information
Version Date Changes
1.8 2022-01-07 Corrected RAM/ROM mode write behaviour
1.7 2021-12-18 Noted wedge save command is not in mini-wedge
1.6 2021-12-02 Corrected mode register information
1.5 2021-08-20 Added example setting RTC, expanded directory
examples
1.4 2018-03-18 Fix references and section levels
1.3 2017-09-09 Added DIP switch settings
1.2 2017-05-01 Added container files
1.1 2017-03-12 Minor corrections
1.0 2017-03-08 First revision
Authors
Simon Rowe <[email protected]>
Page 2
Final Expansion 3 User Guide
Contents
Copyright Information..................................................................................2
Version Information......................................................................................2
Authors..........................................................................................................2
Introduction...................................................................................................6
Where to Get Help........................................................................................6
Cartridge Overview.......................................................................................7
Quick Start....................................................................................................9
Setup.........................................................................................................9
Common Problems.................................................................................10
Start Up Menus...........................................................................................11
Main Menu.............................................................................................11
RAM Manager.......................................................................................12
Disk Loader............................................................................................13
Cartridge Loader....................................................................................14
Secure Digital Drive...................................................................................16
DOS Commands.....................................................................................16
SCRATCH.........................................................................................16
RENAME..........................................................................................16
COPY................................................................................................16
NEW..................................................................................................17
Container Files.......................................................................................17
Disk Images............................................................................................17
Subdirectories.........................................................................................18
Creating Directories..........................................................................18
Changing Directory...........................................................................18
Deleting Directories..........................................................................19
Partitions................................................................................................19
Real Time Clock.....................................................................................20
Reading the RTC...............................................................................20
Setting the RTC.................................................................................21
Other Commands...................................................................................22
Wedge Commands......................................................................................23
Storage Device Commands....................................................................23
Directory Listing...............................................................................23
Page 3
Final Expansion 3 User Guide
Disk Commands................................................................................24
Load BASIC Program.......................................................................24
Load Machine Code Program............................................................24
Save BASIC or Machine Code Program...........................................25
Verify BASIC Program.....................................................................26
Show & Change Drive......................................................................26
Memory Block Commands....................................................................26
Block Disable....................................................................................26
Block Protect.....................................................................................26
I/O Register Disable..........................................................................27
Miscellaneous Commands.....................................................................27
System Reset.....................................................................................27
Wedge Disable...................................................................................27
Program Recovery.............................................................................27
Number Format.................................................................................27
Loader Files................................................................................................29
Program Name.......................................................................................29
Loader Commands.................................................................................29
Disk Commands................................................................................30
Program Loading...............................................................................30
Memory Configuration......................................................................30
Program Launch................................................................................30
Comments..............................................................................................31
Examples................................................................................................31
8K+ Expansion BASIC Program......................................................31
Unexpanded BASIC Program...........................................................32
3K Expansion BASIC Program.........................................................32
Machine Code Program.....................................................................32
Game Cartridge.................................................................................32
Adventure Cartridge..........................................................................33
Directory & Image Navigation..........................................................33
Saving to Flash Memory.............................................................................34
Appendix A – DIP Switches.......................................................................36
Appendix B – Updating Firmware..............................................................37
Appendix C – Programmers Reference......................................................38
Memory Map..........................................................................................38
Page 4
Final Expansion 3 User Guide
Register Descriptions.............................................................................38
Mode register $9C02.........................................................................39
Resource register $9C03...................................................................42
Page 5
Final Expansion 3 User Guide
Introduction
This guide describes the features of the Final Expansion 3 cartridge for the
VIC-20 and how to use them. It also includes reference material for
programmers to write software that uses the advanced capabilities of the
cartridge.
The information given in this guide is believed to be accurate, however
because there are many hardware and software variations the authors
cannot guarantee that a specific system will function exactly as described.
The authors would be grateful to hear from you if you find a mistake or
omission in this guide.
Page 6
Final Expansion 3 User Guide
Cartridge Overview
The Final Expansion 3 (FE3) cartridge expands the VIC-20 with:
• 512KB of Random Access Memory (RAM)
• 512KB of Electrically Erasable Read Only Memory (EEPROM)
• storage to Secure Digital cards emulating a serial bus disk drive
(SD2IEC)
The memory expansion is highly configurable, both from interactive
menus and by commands contained in user-created files. Virtually any type
of memory map can be set up to allow all manner of programs to be run.
Additional commands are available to make disk devices easier to use,
these are provided using a software wedge (which can be disabled) similar
to those that work with physical disk drives such as the 1541.
Loading and saving to serial bus devices is accelerated if they contain
support for JiffyDOS, this includes the integrated SD2IEC device.
The two indicators which are located on the left of the cartridge relate to
the SD2IEC device
• error (top, red) – flashes when an error message is present on the
command channel
• activity (bottom, green) – lit when a file is open on the device
Page 7
Final Expansion 3 User Guide
The two push buttons on the right of the cartridge provide different forms
of system reset
• VIC-20 system reset (top) – system resets but memory
configurations etc. are retained
• VIC-20 and Final Expansion 3 reset (bottom) – system resets with
defaults identical to those at power on.
Page 8
Final Expansion 3 User Guide
Quick Start
This section aims to help the first time user get up and running as quickly
as possible. It also covers likely issues that the user may run into.
Setup
The cartridge should be connected to the VIC-20 with the power switched
off. It may either be inserted directly into the cartridge port or into a slot of
a cartridge expander.
The SD2IEC should then be connected to the serial port of the VIC-20. The
serial port is the rightmost round socket (3) when viewing the rear of the
VIC-20
Some FE3 cartridges have an integral lead with a plug, others have two
sockets. Either
• Connect the plug to the serial port
• Connect one plug of a serial cable into the serial port and one into
either socket on the FE3
An SD card should be prepared on a modern PC by formatting it. Only SD
cards that are FAT formatted can be used with the SD2IEC device.
Page 9
Final Expansion 3 User Guide
Insert the SD card, face down, into the slot on the top of the FE3, it should
click into place. The card may be removed by gently pressing the top of the
card. MicroSD cards may be inserted if an adapter is used.
After checking the cartridge is fully inserted and the serial cable is attached
the VIC-20 can now be powered on.
Common Problems
No startup menu or extra memory but the SD2IEC works correctly
Your cartridge is missing its firmware. See “Appendix B –
Updating Firmware” for how it to flash the cartridge.
Startup menus appear, memory present but SD2IEC device is not
present
Check the cabling between the FE3 and the VIC-20.
Check the DIP switches, see “Appendix A – DIP Switches”.
SD2IEC device is present but it is unable to read or write to the SD
card
Check that the SD card is formatted with a FAT file system. Cards
larger than 32GB may not be compatible, try a smaller capacity
card.
Page 10
Final Expansion 3 User Guide
Start Up Menus
A sequence of menu screens can be used to easily access the features of the
FE3.
Main Menu
When the VIC-20 is powered on a menu with the following options is
presented
• Select common memory configurations
• Load programs from SD2IEC
• Load programs from flash
• Store programs to flash
• Change the SD2IEC device number
Options are selected by pressing the function keys (along with the Shift
key if necessary).
Pressing the F8 key returns from any submenu.
Bypassing the main start up menu can be achieved by holding down one of
the following keys during power on:
• SHIFT – wedge enabled, no additional memory
• C= – wedge disabled, no additional memory
• CTRL – enter “Disk Loader” menu (see below)
The common configuration of all memory blocks being filled is available
by pressing F7 (with the command wedge) or F8 (without the command
wedge).
Page 11
Final Expansion 3 User Guide
RAM Manager
This submenu allows different memory configurations to be set up. After
selection the system will enter BASIC as normal.
F2 8K BLK1 Yes
Page 12
Final Expansion 3 User Guide
F6 - - No
Disk Loader
This submenu allows memory configurations to be set up and program
files to be loaded from the SD card by selecting an entry from a list. The
selections are defined in loader files, see “Loader Files” on page 29 for
details of how to create them.
Page 13
Final Expansion 3 User Guide
The menu is navigated by using either the cursor keys or the joystick, an
entry is selected by pressing RETURN or the fire button. When there is
more than one page of entries the F1 and F3 keys can be used to move
between pages. The F5 and F7 keys can be used to move to the start and
end of a page respectively.
Cartridge Loader
This submenu allows memory configurations to be set up and program
files to be loaded from flash by selecting an entry from a list. In order to
add a selection the following steps must be taken
1. Define the memory configuration, file loading and launching
commands in a loader file (see “Loader Files”)
2. Copy the definition to flash (see “Saving to Flash”)
Once the definition has been written to flash the program can be loaded
and launched without needing the SD card to be present.
Page 14
Final Expansion 3 User Guide
The menu is navigated by using either the cursor keys or the joystick, an
entry is selected by pressing RETURN or the fire button. When there is
more than one page of entries the F1 and F3 keys can be used to move
between pages. The F5 and F7 keys can be used to move to the start and
end of a page respectively.
Page 15
Final Expansion 3 User Guide
DOS Commands
The following commands perform operations in the same manner as
physical disk devices. Only the first character of a command needs to be
given, a : (colon) must be present between the command and any
parameters. Further details of these commands can be found in books such
as “1541 User’s Guide”.
SCRATCH
Deletes one or more files given as parameters. Multiple file names
must be separated by commas, wildcard patterns containing * and ?
may also be used.
RENAME
Changes the name of a file, the existing and replacement file names
are specified as NEWNAME=OLDNAME.
COPY
Creates a duplicate of a file, the new and existing file names are
specified as NEWNAME=EXISTINGNAME.
Page 16
Final Expansion 3 User Guide
If multiple existing files are specified then the new file will contain
the concatenation of them, for example
NEWFILE=START,MIDDLE,END.
NEW
Erases the contents of a disk image (see below). The disk name and
ID must specified as NAME,ID.
This command cannot be used to erase an entire SD card.
Container Files
In order to record the properties of a file that is written directly to the SD
card a container file is used. The suffix of a container file indicates the type
Disk Images
As well as accessing files written directly to the SD card the SD2IEC can
handle image files that represent an entire floppy disk. These images have
track and sector geometry identical to various physical disk devices
Page 17
Final Expansion 3 User Guide
Subdirectories
Subdirectories (directories within directories) may be created, navigated
into and deleted on the SD card. Directories may be referred to as follows
• Relative to the current directory, for example GAMES
• A directory relative to the current directory, for example
/GAMES/ARCADE
• Relative to the root of the SD card, for example
//GAMES/ARCADE
Creating Directories
The MD command creates an empty directory according to the form
of the parameter given. Except when creating a directly below the
current directory the new directory name must be preceded with a :
@MD//GAMES/:QUIZ
Changing Directory
The CD command make the directory specified by parameter the
current directory for future disk operations
@CD/GAMES/ARCADE
@CD:8K
Page 18
Final Expansion 3 User Guide
Deleting Directories
The RD command removes an empty directory. Only subdirectories
of the current directory can be deleted
@RD:MISC
Partitions
SD cards may be contain multiple formatted partitions. Each partition is a
separate logical disk and accessed in a similar manner to physical devices
that have multiple drives or partitions
• Dual disk drives such as the 4040
• Hard disk drives such as the CMD HD-40
The list of partitions present on an SD card can be displayed using the $=P
command
$=P
0 SYSTEM S
1 FIRST N
2 SECOND N
@CP2
$
65535 BLOCKS FREE.
Page 19
Final Expansion 3 User Guide
Advanced Formats
The date and time can be read by program so that each component of the
date and time is available as a separate value. Two formats are available:
decimal and binary coded decimal (BCD), appending D chooses decimal
and B chooses BCD
10 OPEN15,8,15
20 PRINT#15,T-RD
30 FORN=1TO8
40 GET#15,A$
50 A=ASC(A$+CHR$(0))
60 PRINTA;
70 NEXT
80 CLOSE15
RUN
2 117 3 7 9 45
5 1
Page 20
Final Expansion 3 User Guide
The T-W command must be used to set an initial date and time. Any of the
formats described in “Reading the RTC” may be used
@T-WAFRI. 08/20/21 07:
54:00 AM
@
00, OK,00,00
The day of the week must be one of the following four character values
• SUN.
• MON.
• TUES
• WED.
• THUR
• FRI.
• SAT.
Page 21
Final Expansion 3 User Guide
Other Commands
Many other commands are supported by the SD2IEC, some provide
options to the output of other commands. For full details please refer to the
README file linked from https://sd2iec.de/.
Page 22
Final Expansion 3 User Guide
Wedge Commands
The following commands are available in immediate mode, they cannot be
included in BASIC programs. They may also be used in loader programs
see “Loader Files” on page 29.
The wedge interpreter usually resides in BLK5, if the “All RAM” option
was selected in the “RAM Manager” menu then it will reside in the 3K
region within BLK0.
Directory Listing
The $ command can be used to display the contents of an SD card (or disk
image or subdirectory) without overwriting any program in memory
$
16 CATACOMBS P
9 MINOTAUR P
16 NIGHT RACER P
623 BLOCKS FREE.
For long directory listings pressing the CTRL key slows down the rate at
which the screen scrolls.
The list of files displayed can be reduced to those that only match a
wildcard pattern. The character ? matches any character in any position in
the name
$SN?KE
Page 23
Final Expansion 3 User Guide
12 SNAKE P
424 BLOCKS FREE.
The character * matches any number of characters at the end of the name
$TANK*
10 TANK-V-UFO P
11 TANK BATTLE P
424 BLOCKS FREE.
Disk Commands
The @ command can be used to send any of the commands mentioned in
“Secure Digital Drive” on page 16 to the SD2IEC
@R:BOMB=BOMBER
The status of the SD2IEC can be read by using the @ command alone
@
00, OK,00,00
The start and end addresses are displayed in hex, the start address is often
Page 24
Final Expansion 3 User Guide
If the file already exists on the device the following prompt is displayed
63,FILE EXISTS,00,00
Pressing R deletes the existing file and saves the current program with the
file name given
DELETING FILE ...
Pressing U renames the existing file with a ` (single quote) character at the
beginning then saves the current program with the file name given
DELETING OLD FILE ...
RENAMING FILE ...
Page 25
Final Expansion 3 User Guide
OK
Block Disable
The BLKD command causes one or more memory blocks to be disabled.
The blocks affected are appended to the command, multiple blocks are
separated by commas
BLKD1,2,3
Block Protect
The BLKP command causes one or more memory blocks to become read-
only. This can be useful if a program has copy protection to prevent it
being run from RAM. The blocks affected are appended to the command,
multiple blocks are separated by commas
BLKP1,2,3
Page 26
Final Expansion 3 User Guide
Miscellaneous Commands
System Reset
The RESET command can be used to restart the VIC-20. If an autostart
signature is found at the beginning of BLK5 ($A000) then the cold start
routine is called. Otherwise the system enters BASIC.
Wedge Disable
The OFF (or KILL) command can be used to remove the wedge from
memory. Only the standard BASIC commands will be available after
running this command
OFF
Program Recovery
The OLD (or UNNEW) command can be used to restore a BASIC
program that was in memory before the NEW command was run or the
system was reset.
Number Format
The , command can be used to convert numbers between different number
bases
,35
$23 35 #
%00100011
Page 27
Final Expansion 3 User Guide
Page 28
Final Expansion 3 User Guide
Loader Files
In order to define the contents of the “Disk Loader” menu a loader file
needs exist in root of the SD card and in every subdirectory and image file
with programs to be included.
Loader files are BASIC programs that have a specific format and structure.
Loader files are always named LOADER and can be loaded using the /
wedge command
/LOADER
Program Name
The text of the menu entry is defined by a line containing the name
surrounded by " (double quotes). A program name may be up to 20
characters in length and may contain upper and lower case letters.
Loader Commands
The actions to be performed when the menu entry is selected all start with
+ (plus). Commands fall into four categories
1. Disk device commands
2. Commands that load the program
3. Memory configuration commands
4. Commands that launch the program
Commands are performed in the order they appear in the loader file except
commands that launch the program (which are performed last).
Page 29
Final Expansion 3 User Guide
Disk Commands
Disk commands, for example to activate a disk image, may be executed to
prepare the system in some way. Commands start with @" and end with "
(double quotes). Any of the commands mentioned in “Secure Digital
Drive” on page 16 may be used.
Program Loading
One or more files may be loaded by giving the file name surrounded by "
(double quotes). The program type may be given by appending a ,
(comma) and one of
• B – BASIC program, relocated to start of BASIC memory
• P – machine code program, loaded at the start address from the file
(or, optionally, at an address that follows)
• C – cartridge, loaded at an address that follows
A load address is a hexadecimal number prefixed with $ and is separated
from the program type by a , (comma).
Memory Configuration
Any of the following commands described in “Memory Block Commands”
on page 26 may be used to disable or protect specific memory blocks.
Program Launch
To start the program one of the following commands must be used
RUN
Start executing a BASIC program.
SYS
Page 30
Final Expansion 3 User Guide
Comments
Comments may appear anywhere in a loader file. Comments start with :
(colon) and are free-form.
Examples
The following loader file fragments illustrate some of the possible ways of
loading programs. By combining the commands described above almost
any action can be defined.
Page 31
Final Expansion 3 User Guide
Game Cartridge
Most game and utility cartridges contain a ROM that appears at $A000
(BLK5). They automatically start when the system is powered on so are
Page 32
Final Expansion 3 User Guide
Some cartridges have a copy protection check which tries to write to the
memory containing the program. To protect the memory block the BLKP
command can be used
525 +blkp5
Adventure Cartridge
The Scott Adams Adventure cartridges are unusual: they are 16K in size,
loading at $4000; they expect the screen to start at $1E00; and they have a
start address of 32592 ($7F50)
600 :The Count, #5
610 The Count
620 +blkd1
630 +the count,c,$40
00
640 +sys$7f50
In the GRAPHICS directory the loader file should contain the following
100 ../
110 +@cd:
120 +reload
Page 33
Final Expansion 3 User Guide
Page 34
Final Expansion 3 User Guide
Page 35
Final Expansion 3 User Guide
Warning! The VIC-20 must be powered off before changing the switch
settings.
Page 36
Final Expansion 3 User Guide
Page 37
Final Expansion 3 User Guide
Memory Map
The RAM and EEPROM devices occupy separate 19-bit address spaces.
18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Bank Base Offset
Base
A14 A13 Region
0 0 RAM1,2,3
0 0 BLK1
0 1 BLK2
1 0 BLK3
1 1 BLK5
Register Descriptions
Two eight bit registers control the mapping of the RAM and EEPROM
devices into the VIC-20 memory address space.
All registers are initialized to zero at power on.
The register lock bit is set at power on.
Registers are accessible if both
• the lock bit is clear
• bit 7 of the resource register is clear
Page 38
Final Expansion 3 User Guide
7 6 5 4 3 2 1 0
Mode Bank/Parameter
Mode
000 Start mode
010 Super ROM mode
100 RAM 1 mode
110 RAM 2 mode
101 Super RAM mode
011 RAM/ROM
001 Flash mode
Start Mode
Region Reads from Read control Writes to Write control
RAM1,2,3 - - - -
BLK1 - - RAM Bank 1 -
BLK2 - - RAM Bank 1 -
BLK3 - - RAM Bank 1 -
EEPROM Bank
BLK5 - RAM Bank 1 -
0
Any write to an offset in BLK5 clears the register lock bit.
Any read from an offset in BLK5 sets the register lock bit.
Page 39
Final Expansion 3 User Guide
RAM 1 Mode
Region Reads from Read control Writes to Write control
b0 – write
RAM1,2,3 RAM Bank 0 - RAM Bank 0
protect
b1 – 0 = Bank 1,
BLK1 RAM Bank 1 - RAM
1 = Bank 2
b2 – 0 = Bank 1,
BLK2 RAM Bank 1 - RAM
1 = Bank 2
b3 – 0 = Bank 1,
BLK3 RAM Bank 1 - RAM
1 = Bank 2
b4 – 0 = Bank 1,
BLK5 RAM Bank 1 - RAM
1 = Bank 2
RAM 2 Mode
Region Reads from Read control Writes to Write control
b0 – write
RAM1,2,3 RAM Bank 0 - RAM Bank 0
protect
b1 – 0 = Bank 1,
BLK1 RAM RAM Bank 1 -
1 = Bank 2
b2 – 0 = Bank 1,
BLK2 RAM RAM Bank 1 -
1 = Bank 2
b3 – 0 = Bank 1,
BLK3 RAM RAM Bank 1 -
1 = Bank 2
b4 – 0 = Bank 1,
BLK5 RAM RAM Bank 1 -
1 = Bank 2
Page 40
Final Expansion 3 User Guide
RAM/ROM Mode
Region Reads from Read control Writes to Write control
b0 – write
RAM1,2,3 RAM Bank 0 - RAM Bank 0
protect
b1 – 0 = RAM
Bank 1, b1 – 0 = Bank 1,
BLK1 RAM/EEPROM RAM
1 = EEPROM 1 = Bank 2
Bank 0
b2 – 0 = RAM
Bank 1, b2 – 0 = Bank 1,
BLK2 RAM/EEPROM RAM
1 = EEPROM 1 = Bank 2
Bank 0
b3 – 0 = RAM
Bank 1, b3 – 0 = Bank 1,
BLK3 RAM/EEPROM RAM
1 = EEPROM 1 = Bank 2
Bank 0
b4 – 0 = RAM
Bank 1, b4 – 0 = Bank 1,
BLK5 RAM/EEPROM RAM
1 = EEPROM 1 = Bank 2
Bank 0
Page 41
Final Expansion 3 User Guide
Flash Mode
Region Reads from Read control Writes to Write control
RAM1,2,3 - - - -
BLK1 EEPROM Bank b3b2b1b0 EEPROM Bank b3b2b1b0
BLK2 EEPROM Bank b3b2b1b0 EEPROM Bank b3b2b1b0
BLK3 EEPROM Bank b3b2b1b0 EEPROM Bank b3b2b1b0
BLK5 EEPROM Bank b3b2b1b0 EEPROM Bank b3b2b1b0
7 6 5 4 3 2 1 0
e a b 5 3 2 1 r
e – Register disable
0 Registers enabled
1 Registers disabled
5 – BLK5 disable
0 BLK5 enabled
1 BLK5 disabled
3 – BLK3 disable
0 BLK3 enabled
1 BLK3 disabled
2 – BLK2 disable
0 BLK2 enabled
1 BLK2 disabled
Page 42
Final Expansion 3 User Guide
1 – BLK1 disable
0 BLK1 enabled
1 BLK1 disabled
r – RAM1,2,3 disable
0 RAM1,2,3 enabled
1 RAM1,2,3 disabled
Page 43