| Home CBM ASCII-X BASIC C128 2MHz Border BASIC 7.80 BASIC 8 CPM Digimaster 128 Fast Serial for uIEC Games Interlace JiffySoft128 Keyboard Scan Media Player 128 Orig Interlace RGBI to S-Video RGBI to SCART RGBI to VGA RGB Conversion SAM 128 SID Player 128 VDC Interlace Mp128alpha N-progs D64plus Disk Escape Codes Hardware PCxface PETSCII Pet2asc Futurama IBM PC-AT Contact Games Glossary Hall of fame Hall of shame Miscellaneous Privacy policy Programming Twisty puzzles |
The C128 has plenty of RAM (for an 8-bit PC) to allow for multiple programs. This is rarely taken advantage of; the most popular way to do this is with GEOS but it is an entire operating system that renders standard (non-GEOS) software useless! On the Commodore 128 Alive forums a challange was posted by airship to write a utiltity that would allow you to switch between multiple programs. Well this could be a very tall task depending on how far you want to take it. But I decided to do it in a minimal way just to say it has been done. So without further ado, I humbly present...
N-Progs is a set of ML programs for the Commodore 128 that allow multiple BASIC programs to exist in memory at the same time. The download contains a README, the program files as seperate binary files, and all program files stored on one (.D64) disk image. The 'programs' are actually 3 versions of the same program:
The first character of the filename (a number) indicates the number of programs you can have in memory at once (2 or 3). Only the G version should be used with programs that use the VIC bitmap screen (this includes the SPRDEF editor).
There are only 2 steps needed to use N-Progs. First, load and start the version of your choice with:
This will setup BASIC in 'memory space' zero (0). NOTE: This will erase any BASIC program in memory! The second step is to switch memory spaces (change programs) at your leisure with:
where n is the 'memory space' you want to switch to:
You can LOAD, edit, RUN, STOP, CONT, SAVE, a program in a memory space independant of programs in other memory spaces.
Each program has its own area of Bank 0 for program storage. This includes the program along with any embedded DATA or DEFined functions. Using version 3 as an example:
Each program has its own area of Bank 1 for variables. This includes all variables, arrays, and strings. Each program has its own BASIC stack which holds information about FOR/NEXT, DO/LOOP, and GOSUB/RETURN. This is stored in a 512-byte block near the top of Bank 0 when a program is inactive. Using version 3 as an example:
Each program has pointers to memory limits, DATA, current line#, trap line#, error line#, error#, and PRINT USING characters (aka PUDEF) stored in the $FD00 block of memory when inactive. The program of the current memory space has this information copied into special BASIC locations in zero page and page 18 ($12xx). Everything else is shared between all programs. This includes:
BUT, the disk error status, DS$ is written to Bank 1 like normal variables so it is NOT shared (strictly speaking). The program temporarily uses $50~53 when switching memory spaces. Data is stored from $F700 (version 3) or $F900 (version 2,2g) up to $FDFF. The ML program itself lies at $FE00~$FEFD. The current memory space number is stored at $FEFE.
To be compatible with other utilities, the area $1300~$1BFF is NOT used by this program. Neither is the popular zero page memory $FA~$FF. N-Progs will servive a reset. Although reset will erase program 0, you can recall other programs. NOTE: if you need to save your other programs, do so before running any programs in the default program 0 memory space! This is because the reset will cause BASIC to claim all memory for program 0. After saving (if neccessary), use the normal initialization call:
This will reset all memory spaces correctly, but performs a NEW on each in the process.
During a TRAP, the CPU stack is saved and manipulated. This is different from the BASIC stack. TRAP can be used in programs, but your program must NOT switch to another program during the TRAP routine. The TRAP ends and the CPU stack is fixed when the RESUME command is executed. Program switching can occur again after RESUME. SPRITES and the LightPen can cause collissions at any time. It is recommended to not use COLLISSION (not tested). BUMP should be okay. Switching between running programs may fail depending on the types of 'nesting' in use on the stack. My limited tests show this:
© H2Obsession, 2007, 2014 |