This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dos.h> | |
#include <stdio.h> | |
// outport32(): Performs a 32-bit OUT I/O instruction in Borland Turbo C++. | |
// This corresponds to "out dx, eax" command in 386 protected mode assembly. | |
// port: 16-bit I/O port address to write to. | |
// value: a 32-bit value to write. | |
void outport32(unsigned int port, unsigned long value) { | |
// Problem: Borland Turbo C++ is a 16-bit real-mode compiler, so does | |
// not have a 32-bit outport() C API, and its assembler does not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <stdio.h> | |
#include <assert.h> | |
struct region | |
{ | |
uint16_t size; | |
region *next; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "reucpy.h" | |
static volatile uint8_t *const reu_status = (uint8_t*)0xDF00; | |
static volatile uint8_t *const reu_command = (uint8_t*)0xDF01; | |
static volatile uintptr_t *const reu_c64_addr = (uintptr_t*)0xDF02; | |
static volatile reu_addr_t *const reu_cart_addr = (reu_addr_t*)0xDF04; | |
static volatile uint16_t *const reu_xfer_length = (uint16_t*)0xDF07; | |
static volatile uint8_t *const reu_address_ctl = (uint8_t*)0xDF0A; | |
void reucpy(void *c64_addr, reu_addr_t reu_addr, uint16_t size, uint8_t direction) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C64 sprite example with llvm-mos. | |
// Jukka Jylänki. Released to public domain. | |
// Build with -Oz -DNDEBUG for smallest code size (640 bytes). | |
#include <stdint.h> | |
#include <stdio.h> | |
static void TestAssert(bool condition, const char *str, const char *file, int line, const char *func) | |
{ | |
#ifndef NDEBUG // Build with -DNDEBUG to remove this bloating code size | |
if (!condition) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdarg.h> | |
#include "c64/c64_kernal.h" | |
// Prints the given uint16 to CHROUT. | |
static void chrout_u16(uint16_t num) | |
{ | |
uint8_t zp0, zp1, zp2; | |
__asm__(R"( | |
SED // Enter BCD mode (affects ADC commands below) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
// C64 KERNAL ROM functions | |
#include <stdint.h> | |
#include "mystdio.h" | |
#ifdef __C64__ | |
// TODO: Might want to use this form, but can't due to https://github.com/llvm-mos/llvm-mos/issues/392 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Sphere | |
{ | |
float2 pos; | |
float radius; | |
}; | |
struct ArcSector | |
{ | |
float2 pos; | |
float radius; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mergeInto(LibraryManager.library, { | |
preloaded_audio: {}, | |
preload_audio__deps: ['preloaded_audio'], | |
preload_audio: function(id, url) { | |
let audio = new Audio(UTF8ToString(url)); | |
_preloaded_audio[id] = audio; | |
audio.preload = 'auto'; | |
}, | |
play_audio: function(id, loop) { | |
let audio = _preloaded_audio[id]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <emscripten/webaudio.h> | |
#include <emscripten/em_math.h> | |
float phase = 0.f; | |
EM_BOOL ProcessAudio(int numInputs, const AudioSampleFrame *inputs, | |
int numOutputs, AudioSampleFrame *outputs, | |
int numParams, const AudioParamFrame *params, void *userData) { | |
for(int i = 0; i < 128; ++i) { | |
outputs[0].data[i] = emscripten_math_sin(phase); | |
phase = emscripten_math_fmod(phase + 0.05f, 2.f * EM_MATH_PI); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// License: public domain. | |
#include <dos.h> | |
#include <conio.h> | |
void set_video_mode(int mode) | |
{ | |
union REGS regs; | |
regs.x.ax = mode; | |
int86(0x10, ®s, ®s); |
NewerOlder