Skip to content

Instantly share code, notes, and snippets.

@Trinitek
Trinitek / string.c
Created January 11, 2015 05:05
intToString
#include "bool.h"
/*
Return the string representation of a signed or unsigned short.
Does not print leading zeroes.
@param
n - number to convert
s - true if n is signed, false if unsigned
buffer - seven character string buffer to write to, including null-terminator
@Trinitek
Trinitek / string.c
Created January 11, 2015 06:13
String matching example
// ===== IN MAIN.C =====
// Test string matching
static char str1[] = "ABCD";
static char str2[] = "ABCD";
static char str3[] = "EFGH";
static char match[] = "Match!";
static char nomatch[] = "No match.";
if (stringMatch(&str1, &str2)) print(&match, 1, 1, 15);
@Trinitek
Trinitek / api.txt
Created January 18, 2015 02:00
MikeOS Mouse Library API
MikeOS Mouse Library
Version 1.1.0
API Document
Function: mouselib_install_driver
Input: Nothing
Output: Nothing
Description: Initialises the mouse device and installs the mouse driver that handles
the core library fuctionality. The driver will then continue to run in the background.
This must be run before calling any other mouse functions.
#ifndef _INPUT_H
#define _INPUT_H
#include "bool.h"
#define KEY_UP 72
#define KEY_DOWN 80
#define KEY_LEFT 75
#define KEY_RIGHT 77
@Trinitek
Trinitek / sine3.asm
Created January 24, 2015 04:51
Sine waves r fun
_COLOR equ 0x0F
org 0x100
start:
mov ax, 0x13
int 0x10
mov ax, 0xA000
#include <stdio.h>
#include <stdbool.h>
void print(char* str);
bool isNumeric(char c);
bool isAlpha(char c);
bool stringMatch(char* str1, char* str2);
void main(void) {
char* welcome = "Hello 123 world!";
org 0x100
main:
mov si, hello_str
call printString
mov ax, 1
mov bh, 3
mov bl, 5
#include <stdio.h>
#include <stdlib.h>
void main(void) {
char blocks[] = "[][[][][[[]][]][]]";
printf("_ | block: 0, depth: 0\n");
fpu_controlWord dw ?
macro nSaveControlWord {
mov ax, [fpu_controlWord]
}
macro nRestoreControlWord {
mov [fpu_controlWord], ax
fclex
@Trinitek
Trinitek / List.c
Created November 26, 2015 11:00
Java-style ArrayLists in C
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
typedef char* String;
typedef struct {
bool valid;