Skip to content
/ C-honky Public

A custom language that compiles to ChonkyPC machine code

Notifications You must be signed in to change notification settings

HUSKI3/C-honky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img

C-honky

🐈
A functional language for the ChonkPC CPU
C-honky pronounced "chonk-ee" is a programming language designed for the ChonkPC platform, it's able to create executable bytecode for generating a BIOS and soon programs to be loaded by the ChonkPC emulator.

Built with ❤︎ by Liuk707 and Artur (aka Huski3)

Table of Contents

  • Features
  • Example
  • Philosophy
  • Functions
  • Libraries

Features

  • minimal size: generated binaries are optimized out of the box
  • function driven: c-honky is a functional language, making anything possible
  • little boilerplate: barely any boiler plate is required to start having fun with this language
  • minimal tooling: both compiler and assembler are bundled as one library
  • supports namespaces: namespaces are easy to set up and use
  • very cute: Named after Liuk's cat!

Example

Hello world in C-honky:

// test.ck
// Include our standard library
#embed[ck] "std.ck"

std::println("Hello World!");

Want to see more examples? Check out the Handbook.

Philosophy

ChonkPC is a minimal 32bit CPU built from the ground up, therefore there is no compiler or assembler developed directly for it. C-honky provides a simplistic low level language to abstract >30k assembly lines of boilerplate code, it provides enough to be used for calculations, graphics, disk operations and more to come! The language syntax and semantics concept was first based on the toy language Pyetty, that was written entirely in Python. The syntax has been expanded to allow for lower level communication with the CPU and other components provided by the ChonkPC emulator.

Functions

The entire language relies on the use of functions to decrease code redundancy and performance. Each functions address is stored in memory to be used later.

Creating a function is as simple as providing the name and it's code block. Currently no return statements are supported

// ...
func  HelloWorld(int  test1) void {
	if (test1  ==  1) {
		std::println("I'm one!");
	}
}
HelloWorld(1);
// Output: I'm one!

Libraries

img

Currently C-honky has the following libraries:

  • std.ck - Standard library
  • gl.ck - Graphics library
  • disk.ck - Abstracted Disk library
  • dif.ck - Disk Interface

Standard library

The standard library provides the ability to write to the console, ... and panic. Not much else is implemented there yet. The print and println functions have a limit of 100 characters.

// Hello world with a panic!
#embed[ck] "std.ck"
std::print("Hello ");
std::println("world!");

if (1 != 0) {
	std::panic("[FATAL] Oh no! Math!");
}

Graphics library

The graphics library works directly with the GPU by writing to different addresses to define properties of the triangles to be drawn, and then calls draw on them. You must clear the command fifo before writing again.

Examples:

// Gradient triangle example
#embed[ck] "gl.ck"

// Clear screen
GL::clear(0, 0, 0);

// Colours
int r =  50;
int g =  150;
int b =  200;

// Triangle
GL::tri( 120, 400,
	520, 400,
	320, 100,
	r, g, b,
	b, g, r,
	g, r, b
);

GL::draw_double();

Disk and others are a WIP

About

A custom language that compiles to ChonkyPC machine code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages