Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works
Anything · Lazarus or Delphi
Random projectRandom project

grcalc

An MS-DOS graphic calculator written in Turbo Pascal, updated to run on Mac OS using Free Pascal

View on GitHub

Member rating

No ratings yet.

Sign in to rate this project.

README

GrCalc - Graph Calculator

GrCalc Logo

A modernized version of a 1990s TurboPascal 7 graph calculator application, adapted for Free Pascal.

Original Program

This is "A Proper Graph Calculator" written in 1995-1996. It was a DOS-based graphical application that allowed users to:

  • Plot mathematical equations (two equations simultaneously)
  • Pan and zoom the graph view
  • Find roots, y-intercepts, and intersection points
  • Use trigonometric functions (sin, cos, tan) and natural logarithm

History

I've written about the history of this in a blog post.

Compilation

Prerequisites

  1. Free Pascal Compiler
    bash
    brew install fpc
  2. SDL2 (for graphics support)
    bash
    brew install sdl2

Building

bash
make

This will produce the grcalc executable in the project root.

Project Structure

pascal
grcalc/
????????? original/           # Original unmodified 1996 source files
???   ????????? GRCLC120.PAS   # Main program
????????? src/               # Modernized source files
???   ????????? GRCLC120.pas   # Modified main program
???   ????????? Button.pas     # Recreated GUI button system
???   ????????? Mouse.pas      # SDL2-based mouse handling
???   ????????? Stack.pas      # Stack data structure for expression parsing
???   ????????? Graph.pas      # TurboPascal Graph API compatibility layer (SDL2)
????????? Makefile

Changes from Original

The following modifications were made to run on modern systems:

Main Program (GRCLC120.pas)

  • Added {$mode objfpc} directive for Free Pascal compatibility
  • Changed uses clause from Graph to custom Graph unit
  • Replaced DOS port access (port[]) with no-op stubs
  • Changed graph driver path from 'c:\tp7\bgi' to ''

Recreated Units

  • Button.pas: Complete recreation based on usage analysis
  • Mouse.pas: SDL2-based implementation replacing DOS interrupts
  • Stack.pas: Simple stack for expression parsing (string and real)
  • Graph.pas: TurboPascal Graph API implemented using SDL2
  • SDL2 Units: Included src/sdl2/ from SDL2-for-Pascal to ensure cross-platform compatibility (especially macOS Apple Silicon).

Known Issues

Mouse Interaction

Mouse coordinates might need calibration depending on window scaling and High-DPI displays.