Hi65: a high-level Commodore 65 emulator
created by Devil Master


History - About - Screenshots - Downloads


Please consider a donation if you use Hi65 and would like to support future development. Thank you!
History
What's new in version 9:
* Implemented the RND instruction, which initializes the pseudorandom number generator with the current timer value and returns a result if its parameter is zero, returns a new result with the current initialization if the parameter is positive, and initializes the pseudorandom number generator with its parameter if it's negative. (NOTE: for now, the values of the pseudorandom numbers will not coincide with those generated on a physical C65, even though the effect of the instruction as described in the manual is reproduced to the letter, because the standard srand() and rand() functions of C are used, rather than the formula from the original BASIC 10.)
* Extended the default expression evaluator, to support negative numbers or variables as parameters for mathematical functions.
* Added checks in the Let, If, Input and Print functions to prevent the user from using variables called DO, FN, GO, IF, ON, OR, TO (which would be tokenized as commands and prevent the program from working).
* Fixed a bug in the Next function, which used to make it exit loops after a single iteration if a colon was present after the corresponding FOR instruction
* Extended the Dim function so that multiple arrays, separated by commas, can be declared with a single instruction.
* Fixed a bug in the function that transforms expressions into a format MuParser can understand, which used to work incorrectly with negative variables being multiplied, divided or elevated to power.
* Fixed a bug in the keyboard input routine, that used to make the character display sluggish on Windows 10.
UPDATE 9.1: Fixed a related bug, only apparent on Windows 10, that sometimes prevented the application to release the screen after quitting. Fixed the proportions in the alternative screen layouts (GOPET, GO20, GO16, GO64, GO128) and sped up their creation. Implemented font and color selection in the frontend.

What's new in version 8:
* Added support for additional resolutions (1360*768 and 1440*900).
* Rewrote the zoom routines for the instructions BOX, CIRCLE, DRAW, ELLIPSE and LINE, to make them more compact and have them accept more zoom values (for running the emulator at different resolutions) up to 6x.
* Implemented the GOSUB instruction.
* Added a partial implementation of the ASC instruction (to return the ASCII value of the first character of a string, with no string operations for now).
* Extended the PRINT instruction to support string chaining (with the operator + ) and the CHR$ parameter (to turn an ASCII code into a character).
* Fixed a bug in the frontend that used to corrupt the status of the MuParser flag.
* Fixed a bug that used to crash the program if a pixel was drawn beyond the edge of the current resolution.
UPDATE 8.1: fixed a bug in the string array that used to hang the emulator when a file with a name shorter than 16 characters was opened. Removed leftover debug code.
UPDATE 8.2: redefined the Gosub stack as an unsigned integer array to let it accept addresses greater than 255. Fixed a bug in the default (=non-MuParser) expression evaluator for a correct evaluation of multiple variable assigns separated by colons.

What's new in version 7:
* Changed the types of the program counter, data counter and expression counter from unsigned integer to unsigned long to allow for longer programs.
* Modified the keyboard handling functions so that they yield CPU time every time they are called
* Fixed a bug in the INPUT# instruction that used to leave the file open after the program terminates for attempting to read past EOF.
* Added a check in the LET instruction that stops the execution of a program if a string is over 255 characters long.
* Implemented string chaining with the operator + , with an arbitrary number of strings (up to the limit of 255 characters).
* Fixed a bug in the PRINT instruction that prevented the cursor from going to the next line when a single instruction displays more characters than a line can fit.
* Implemented the LEN instruction, to know the length of a string or chain of strings.
* Implemented the RESTORE instruction, to move the data counter to the desired line or to the beginning of the data section.
* Added checks in both the frontend and the main executable to force the emulator to run in full screen when launched from the frontend, to avoid an "invalid video mode" error.
* Added a check that recognizes attempts to execute an empty program file and skips them.

What's new in version 6:
* Included a fix for a COMDLG32.OCX error that happens on certain Windows systems when attempting to run Hi65 Edit and Launch Tool. Note that the fix must be installed manually, following the included instructions.
* Fixed a bug in the text wraparound check that used to crash Hi65 if text reached the bottom of the screen in certain resolutions.
* Implemented the CLR instruction, to clear all variables, loop stacks, open streams and data pointer during the course of a program.
* Implemented the EXP mathematical function (the mathematical expression exp(x) equals to e^x).
* Implemented the HELP instruction (only as an immediate command, to display the line that returned an error during the execution).
* Implemented the CHR$, HEX$, LEFT$, MID$ and RIGHT$ string operations (note: for now, they only work in variable assigns, not as part of a PRINT command).

What's new in version 5:
* Incorporated Ingo Berg's MuParser routines into Hi65. They form an open source evaluator of mathematical expressions, that enables Hi65 to evaluate and calculate expressions (e.g. for variable assigns) with an even higher complexity than what a physical Commodore 65 could do. However, they are disabled by default in Hi65 for speed reasons (the native Hi65 expression evaluator is limited to expressions with at most one operator, but is over 275 times faster to evaluate them). The MuParser routines can be toggled on or off with the Hi65cfg utility, from the Hi65 Edit and Launch Tool, or directly from Hi65 with a pseudocommand (see below).
* Implemented a BASIC 10 pseudocommand to enable, disable or verify the status of MuParser within Hi65. The syntax is: MUPARSER 0 to disable it, MUPARSER 1 to enable it, and just MUPARSER to display a message telling you whether it's currently on or off. It works either from the command line or from within a BASIC 10 program.
* Added 36 new error messages that do not appear in the physical Commodore 65, that are triggered whenever MuParser fails to evaluate an expression for some reason. This does not affect compatibility and makes debugging programs easier because they are more specific than a generic "SYNTAX ERROR" could ever be.

What's new in version 4:
* Implemented the SPC and TAB parameters in the PRINT function (respectively, to display the specified amount of spaces and move the cursor to the specified column).
* Fixed a bug in the LOCATE function that used to add the screen border twice instead of once to the cursor position.
* Fixed a bug in the DLOAD function that used to hang the emulator if a syntax error was made when entering the command.
* Fixed a bug in the LET function that used to leave residual characters of a previous string initialization, if the new value was shorter than the older one.
* Implemented the system timer. This counts the 60ths of a second elapsed since the C65 was switched on (or, in this case, since the emulator was launched) and stores the value into the numeric variable TI. Instead, the string variable TI$ contains the system time, like it would in a C65 with a real-time clock.
* Implemented the SCNCLR function.
* Implemented the support of sequential files, with the functions DOPEN, APPEND, DCLOSE, INPUT# and PRINT#. This makes it possible to read and write files from within a BASIC 10 program.
* Added a new feature to the Windows frontend: a menu called Paths, from which you can now tell the frontend where the Hi65 and VICE executables are located. The default is that both are located in the same directory as the frontend, which is true for Hi65, but if you want to use the frontend with VICE without moving files around, you'll have to use the appropriate option of the Paths menu to specify the VICE directory.
* Fixed a bug in the frontend that used to make the "Launch with current program" button work incorrectly.
UPDATE 4.1: Optimized and debugged the INPUT function, to prevent it from corrupting the data when reading a negative non-integer.

What's new in version 3:
* Fixed a bug in the function that loads the configuration: if a configuration file was not found, the program used to crash; now instead it creates a default configuration file.
* Rewrote the part of the PRINT function that deals with numbers, to make it display non-integers correctly.
* Modified the functions that work on non-integers so that they use doubles instead of floats, to increase precision.
* Made a major overhaul to the Windows frontend, which now allows you to write and modify BASIC 10 programs directly, instead of relying on an external text editor. The GUI of the frontend is now different too, more complete and professional. To reflect the change, the name of the frontend is now Hi65 Edit and Launch Tool.
UPDATE 3.1: Fixed a resizing bug in the frontend. Corrected the icons when another version of Commodore BASIC is selected.

What's new in version 2:
* Fixed a bug in the expression evaluator, so that goniometric functions also accept variables (only numeric, of course).
* Fixed a bug in the CHAR function, so that it also accepts variables (only strings - a limitation of the original instruction on the C65).
* Fixed a bug in the function that reads the instruction end address, so that it is also read correctly whenever its least significant byte happens to be zero.
* Added the support for more HD resolutions.
* Added the support for windowed mode. Note that running Hi65 from the launch tool will modify the configuration file to force it to full screen anyway, because launching it in windowed mode from the launch tool would cause it to crash. Instead, configuring it to any mode (windowed or full screen) with hi65cfg.exe and then running hi65.exe will run it correctly in whatever mode you select.
* Added a flashing cursor whenever Hi65 is accepting keyboard input.
* Added a wraparound check that returns the text cursor to the top of the screen whenever the bottom of the screen is reached.
* Implemented 1-dimensional arrays for numbers and strings, with a maximum number of 256 elements (from 0 to 255). This also includes the ability to use an element of an array as an index in a FOR cycle, which was not possible in an actual C65.
* Just for fun, added alternative interfaces to the emulator, resembling screens of other Commodore computers. To try them, use the following commands: GO64, GO128, GO16, GO20, GOPET. To return to the classic interface: GO65. Note that the changes are merely aesthetical, with no difference in functionality or scope of the emulator.

What's new in version 1:
* It can load programs at launch time, by specifying the name of the program as a parameter in the command line
* It can load programs at run time, by using the DLOAD command
* It can run a consistent subset of BASIC 10 instructions, although, for now, mathematical expressions need to have at most one operator
* It can perform extremely fast graphical operations, with an accuracy and speed exceeding those on MESS or on a physical Commodore 65 of various orders of magnitude.


About
The Commodore 65 is an unreleased computer from Commodore featuring 256-color graphics, a 3.54 MHz processor and a maximum of 8 MB of RAM.

Hi65 is a high-level Commodore 65 emulator.

In order to understand what "high-level" means, let's first consider what a "low-level" emulator does. It implements a software version of the whole machine, including a virtual processor that executes machine language commands. When any software for the target platform is loaded into the virtual RAM, the virtual processor executes it instruction by instruction.
However, the Commodore 65 is not the ideal platform for a low-level approach: each of the few units around has a different implementation of its ROM software, the implementations themselves are buggy and there is no commercial software around. The authors of MESS want to emulate the Commodore 65 with a low-level approach, but that has been a failure: the C65 driver of MESS has had the same bugs for over a decade, bugs that do *not* appear in the actual C65 prototypes. Emulating the Commodore 65 with a low-level approach is not "accurate" and it's more than pedantic: it's a self-defeating task.

Enter Hi65.

Hi65 does not implement a virtual version of the 4510 CPU (used in the physical Commodore 65), nor does it execute machine code software: it executes tokenized BASIC 10 programs directly, as if the various BASIC tokens were machine code instructions for its own virtual processor. Thus, the execution is much faster because it's not limited to the clock speed of the 4510 (but the timing is still accurate) and it's not limited by the scarce knowledge of the inner workings of the Commodore 65, because all instructions are made to do what the manual says they should do, not what they actually do on a physical machine (which may be buggy and inconsistent between individual machines).

The high-level approach makes Hi65 much faster than MESS, and even faster than the original machine. The gfxdemo1 program is completed correctly in a tenth of a second in Hi65. The same program takes 4 minutes and 44 seconds to be completed on MESS 0.106 with throttle off. This means that the high-level approach chosen with Hi65 makes it 2840 times faster than MESS. The same program is completed in about 20 minutes on a physical Commodore 65, which means Hi65 is 12000 times faster than a physical Commodore 65.

Hi65 (the emulator), Hi65CFG (the configuration software) and Hi65 Edit and Launch Tool (the graphical frontend) are released under version 3 of the GPL (GNU General Public License). If you do not have a copy of the license, go to http://www.gnu.org/licenses/gpl.html to read it.

Screenshots:
name.prg
gfxdemo1.prg
gfxdemo2.prg
gfxdemo3.prg
clock.prg
laser.prg
mandelbrot.prg
cartesian.prg
Downloads
Emulator:
Download Hi65 v9.1 (1.71 MB)
(JOKE) Download Hi65 for Amiga 500 (1062 KB) (the Amiga version of Hi65 is just a gag for April Fools Day)

Example programs:
Download name or read the source code
Download ssample or read the source code
Download gfxdemo1 or read the source code
Download gfxdemo2 or read the source code
Download gfxdemo3 or read the source code
Download clock or read the source code
Download laser or read the source code
Download mandelbrot or read the source code
Download gfxdemo1-640 or read the source code
Download cartesian or read the source code
Download turtle or read the source code



Are you a Commodore enthusiast? You can find a whole lot of Commodore material on Amazon. Remember: Hi65 will always be free!