Start of F256lib amalgamated build.

This commit is contained in:
Scott Duensing 2024-03-27 19:54:24 -05:00
parent d64a68da17
commit 72a6812c1a
29 changed files with 335 additions and 108 deletions

1
.gitignore vendored
View file

@ -44,6 +44,7 @@ include/
generated/
overlay
overlayhelper
f256lib.h
# Dumb QtCreator junk
build-*/

76
build-f256lib.sh Executable file
View file

@ -0,0 +1,76 @@
#!/bin/bash -ex
#
# Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
TARGET=f256lib.h
cat f256lib/stddclmr.h > ${TARGET}
echo "#define F256LIB_AMALGAMATED_BUILD" >> ${TARGET}
cat f256lib/f_api.h >> ${TARGET}
cat include/f256_dma.h >> ${TARGET}
cat include/f256_intmath.h >> ${TARGET}
cat include/f256_irq.h >> ${TARGET}
cat include/f256jr.h >> ${TARGET}
cat include/f256_rtc.h >> ${TARGET}
cat include/f256_sprites.h >> ${TARGET}
cat include/f256_tiles.h >> ${TARGET}
cat include/f256_timers.h >> ${TARGET}
cat include/f256_via.h >> ${TARGET}
cat include/f256_xymath.h >> ${TARGET}
cat f256lib/f256.h >> ${TARGET}
cat f256lib/f_kernel.h >> ${TARGET}
cat f256lib/f_dma.h >> ${TARGET}
cat f256lib/f_math.h >> ${TARGET}
cat f256lib/f_random.h >> ${TARGET}
cat f256lib/f_text.h >> ${TARGET}
cat f256lib/f_bitmap.h >> ${TARGET}
cat f256lib/f_tile.h >> ${TARGET}
cat f256lib/f_graphics.h >> ${TARGET}
cat f256lib/f_sprite.h >> ${TARGET}
cat f256lib/f_file.h >> ${TARGET}
cat f256lib/f_platform.h >> ${TARGET}
echo "#ifdef F256LIB_IMPLEMENTATION" >> ${TARGET}
cat f256lib/f256.c >> ${TARGET}
cat f256lib/f_kernel.c >> ${TARGET}
cat f256lib/f_dma.c >> ${TARGET}
cat f256lib/f_math.c >> ${TARGET}
cat f256lib/f_random.c >> ${TARGET}
cat f256lib/f_text.c >> ${TARGET}
cat f256lib/f_bitmap.c >> ${TARGET}
cat f256lib/f_tile.c >> ${TARGET}
cat f256lib/f_graphics.c >> ${TARGET}
cat f256lib/f_sprite.c >> ${TARGET}
cat f256lib/f_file.c >> ${TARGET}
cat f256lib/f_platform.c >> ${TARGET}
echo "#endif" >> ${TARGET}

View file

@ -33,11 +33,10 @@ PATH=${LLVM}/bin:${PATH}
echo "__f256_start = ${START};" > ${SETTINGS}
CLANG="mos-f256k-clang -I${F256}/include -I${F256}/f256lib -Wall -O3"
CLANG="mos-f256k-clang -I${F256}/include -I${F256}/f256lib -Wall -Os"
${CLANG} -c ${F256}/f256lib/f256.c
${CLANG} -c ${PROJECT}.c
${CLANG} -o ${PROJECT} ${PROJECT}.o f256.o
${CLANG} -o ${PROJECT} ${PROJECT}.o
mv -f ${PROJECT} ${PROJECT}.bin

View file

@ -21,7 +21,8 @@
*/
#include "f256.h"
#define F256LIB_IMPLEMENTATION
#include "../../f256lib.h"
void dirtest(void) {
@ -67,14 +68,12 @@ void dirtest(void) {
}
int main(void) {
int main(int argc, char *argv[]) {
struct time_t clock;
f256Init();
//dirtest();
while(true) {
while (true) {
kernelNextEvent();
kernelArgs->common.buf = &clock;
kernelArgs->common.buflen = sizeof(struct time_t);

View file

@ -21,41 +21,19 @@
*/
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#ifndef WITHOUT_KERNEL
#include "kernel.c"
#endif
#ifndef WITHOUT_DMA
#include "dma.c"
#endif
#ifndef WITHOUT_MATH
#include "math.c"
#endif
#ifndef WITHOUT_RANDOM
#include "random.c"
#endif
#ifndef WITHOUT_TEXT
#include "text.c"
#endif
#ifndef WITHOUT_BITMAP
#include "bitmap.c"
#endif
#ifndef WITHOUT_TILE
#include "tile.c"
#endif
#if !(defined WITHOUT_BITMAP || defined WITHOUT_TILE || defined WITHOUT_SPRITE)
#include "graphics.c"
#endif
#ifndef WITHOUT_SPRITE
#include "sprite.c"
#endif
#ifndef WITHOUT_FILE
#include "file.c"
#endif
#ifndef WITHOUT_PLATFORM
#include "platform.c"
#include "f_kernel.c"
#include "f_dma.c"
#include "f_math.c"
#include "f_random.c"
#include "f_text.c"
#include "f_bitmap.c"
#include "f_tile.c"
#include "f_graphics.c"
#include "f_sprite.c"
#include "f_file.c"
#include "f_platform.c"
#endif

View file

@ -21,6 +21,70 @@
*/
/*
* Configuration DEFINEs
*
* Before including this file, you may define one or more of the following
* to customize the library for your application:
*
* SWAP_RESTORE
*
* When using functions such as FAR_PEEK or bitmap features, return the
* swap slot back to it's original memory location before returning. By
* default, the swap slot is left in whatever state the last function that
* used it switched it to.
*
* WITHOUT_GRAPHICS
*
* Shortcut for WITHOUT_BITMAP, WITHOUT_TILE, and WITHOUT_SPRITE.
*
* WITHOUT_BITMAP
*
* Disables bitmap functions.
*
* WITHOUT_TILE
*
* Disables tilemap functions.
*
* WITHOUT_SPRITE
*
* Disables sprite functions.
*
* WITHOUT_FILE
*
* Disables file handling support.
*
* WITHOUT_KERNEL
*
* Disables microkernel support. Also disables FILE, PLATFORM, and MAIN.
*
* WITHOUT_TEXT
*
* Disables text functions. Also disables PLATFORM.
*
* WITHOUT_MATH
*
* Disables math coprocessor support. Also disables TEXT, PLATFORM and
* BITMAP.
*
* WITHOUT_MAIN
*
* Removes support for the standardized "int main(int argc, char *argv[])"
* function and replaces it with "int main(void)". You must also manually
* call "f256Init()" at the start of your program.
*
* WITHOUT_PLATFORM
*
* Removes basic C library I/O support for "getchar()" and "__putchar()".
* This removes printf().
*
* WITHOUT_DMA
*
* Removes DMA support. In the future, will also disable BITMAP.
*
*/
#ifndef F256_H
#define F256_H
@ -34,10 +98,10 @@ extern "C"
#include <stdlib.h>
#include <stdio.h>
#ifndef F256LIB_AMALGAMATED_BUILD
#include "stddclmr.h"
#include "api.h"
#include "f_api.h"
#include "f256_dma.h"
#include "f256_intmath.h"
#include "f256_irq.h"
@ -48,6 +112,7 @@ extern "C"
#include "f256_timers.h"
#include "f256_via.h"
#include "f256_xymath.h"
#endif
typedef unsigned char byte;
@ -165,69 +230,44 @@ typedef struct colorS {
// Verify configuration DEFINEs.
#if (defined WITHOUT_BITMAP && defined WITHOUT_TILE && defined WITHOUT_SPRITE)
#define WITHOUT_GRAPHICS
#endif
#ifdef WITHOUT_GRAPHICS
#define WITHOUT_BITMAP
#define WITHOUT_TILE
#define WITHOUT_SPRITE
#endif
#ifndef WITHOUT_FILE // File requires Kernel
#ifdef WITHOUT_KERNEL
#error "FILE requires KERNEL."
#endif
#define WITHOUT_FILE
#define WITHOUT_MAIN
#define WITHOUT_PLATFORM
#endif
#ifdef WITHOUT_TEXT
#define WITHOUT_PLATFORM
#endif
#ifndef WITHOUT_TEXT // Text requries Math
#ifdef WITHOUT_MATH
#error "TEXT requires MATH."
#endif
#endif
#ifndef WITHOUT_BITMAP // Bitmap requries Math
#ifdef WITHOUT_MATH
#error "BITMAP requires MATH."
#endif
#endif
#ifndef WITHOUT_MAIN // Main requries Kernel
#ifdef WITHOUT_KERNEL
#error "MAIN requires KERNEL."
#endif
#define WITHOUT_TEXT
#define WITHOUT_PLATFORM
#endif
#ifndef WITHOUT_KERNEL
#include "kernel.h"
#endif
#ifndef WITHOUT_DMA
#include "dma.h"
#endif
#ifndef WITHOUT_MATH
#include "math.h"
#endif
#ifndef WITHOUT_RANDOM
#include "random.h"
#endif
#ifndef WITHOUT_TEXT
#include "text.h"
#endif
#ifndef WITHOUT_BITMAP
#include "bitmap.h"
#endif
#ifndef WITHOUT_TILE
#include "tile.h"
#endif
#if !(defined WITHOUT_BITMAP || defined WITHOUT_TILE || defined WITHOUT_SPRITE)
#include "graphics.h"
#endif
#ifndef WITHOUT_SPRITE
#include "sprite.h"
#endif
#ifndef WITHOUT_FILE
#include "file.h"
#endif
#ifndef WITHOUT_PLATFORM
#include "platform.h"
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_kernel.h"
#include "f_dma.h"
#include "f_math.h"
#include "f_random.h"
#include "f_text.h"
#include "f_bitmap.h"
#include "f_tile.h"
#include "f_graphics.h"
#include "f_sprite.h"
#include "f_file.h"
#include "f_platform.h"
#endif
@ -250,4 +290,11 @@ void FAR_POKEW(uint32_t address, uint16_t value);
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#ifdef F256LIB_IMPLEMENTATION
#include "f256.c"
#endif
#endif
#endif // F256_H

View file

@ -21,8 +21,13 @@
*/
#include "bitmap.h"
#include "dma.h"
#ifndef WITHOUT_BITMAP
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_bitmap.h"
#include "f_dma.h"
#endif
static uint16_t _MAX_X;
@ -246,3 +251,6 @@ void bitmapSetVisible(byte p, bool v) {
break;
}
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef BITMAP_H
#define BITMAP_H
#ifndef WITHOUT_BITMAP
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void bitmapClear(void);
@ -51,4 +54,5 @@ void bitmapSetVisible(byte p, bool v);
#endif
#endif
#endif // BITMAP_H

View file

@ -21,7 +21,12 @@
*/
#include "dma.h"
#ifndef WITHOUT_DMA
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_dma.h"
#endif
static void dmaWait(void);
@ -66,3 +71,6 @@ static void dmaWait(void) {
// Then wait for a VBL because two DMAs per frame will crash.
//graphicsWaitVerticalBlank();
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef DMA_H
#define DMA_H
#ifndef WITHOUT_DMA
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void dmaFill(uint32_t start, uint32_t length, byte value);
@ -43,4 +46,5 @@ void dma2dFill(uint32_t start, uint16_t width, uint16_t height, uint16_t stride,
#endif
#endif
#endif // DMA_H

View file

@ -21,9 +21,14 @@
*/
#ifndef WITHOUT_FILE
#include <string.h>
#include "file.h"
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_file.h"
#endif
#define MAX_DRIVES 8
@ -484,3 +489,4 @@ static char *pathWithoutDrive(char *path, byte *drive) {
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef FILE_H
#define FILE_H
#ifndef WITHOUT_FILE
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
typedef struct fileDirEntS {
@ -91,4 +94,5 @@ int16_t fileWrite(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd);
#endif
#endif
#endif // FILE_H

View file

@ -21,7 +21,12 @@
*/
#include "graphics.h"
#ifndef WITHOUT_GRAPHICS
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_graphics.h"
#endif
void graphicsDefineColor(byte clut, byte slot, byte r, byte g, byte b) {
@ -102,3 +107,6 @@ void graphicsWaitVerticalBlank(void) {
// Spin our wheels.
;
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef GRAPHICS_H
#define GRAPHICS_H
#ifndef WITHOUT_GRAPHICS
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void graphicsDefineColor(byte clut, byte slot, byte r, byte g, byte b);
@ -46,4 +49,5 @@ void graphicsWaitVerticalBlank(void);
#endif
#endif
#endif // GRAPHICS_H

View file

@ -21,7 +21,12 @@
*/
#include "kernel.h"
#ifndef WITHOUT_KERNEL
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_kernel.h"
#endif
kernelEventT kernelEventData; // Allocate some RAM to hold event data.
@ -132,3 +137,6 @@ void kernelReset(void) {
// ***TODO*** Network
*/
#endif

View file

@ -23,6 +23,7 @@
#ifndef KERNEL_H
#define KERNEL_H
#ifndef WITHOUT_KERNEL
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
#define kernelNextEvent() ({ kernelEventData.type = 0; kernelCall(NextEvent); })
@ -70,4 +73,5 @@ void kernelReset(void);
#endif
#endif
#endif // KERNEL_H

View file

@ -21,7 +21,12 @@
*/
#include "math.h"
#ifndef WITHOUT_MATH
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_math.h"
#endif
int16_t mathSignedDivision(int16_t a, int16_t b) {
@ -124,3 +129,6 @@ uint32_t mathUnsignedMultiply(uint16_t a, uint16_t b) {
POKEW(MULU_B_L, b);
return PEEKD(MULU_LL);
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef MATH_H
#define MATH_H
#ifndef WITHOUT_MATH
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
int16_t mathSignedDivision(int16_t a, int16_t b);
@ -48,4 +51,5 @@ uint32_t mathUnsignedMultiply(uint16_t a, uint16_t b);
#endif
#endif
#endif // MATH_H

View file

@ -21,7 +21,12 @@
*/
#include "platform.h"
#ifndef WITHOUT_PLATFORM
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_platform.h"
#endif
// printf() support.
@ -48,3 +53,4 @@ int getchar(void) {
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef PLATFORM_H
#define PLATFORM_H
#ifndef WITHOUT_PLATFORM
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void __putchar(char c);
@ -43,4 +46,5 @@ int getchar(void); // This is an int so llvm-mos finds it.
#endif
#endif
#endif // PLATFORM_H

View file

@ -21,7 +21,12 @@
*/
#include "random.h"
#ifndef WITHOUT_RANDOM
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_random.h"
#endif
uint16_t randomRead(void) {
@ -50,3 +55,5 @@ void randomSeed(uint16_t seed) {
POKE(VKY_RND_CTRL, 3); // Enable, load seed.
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef RANDOM_H
#define RANDOM_H
#ifndef WITHOUT_RANDOM
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
uint16_t randomRead(void);
@ -44,4 +47,5 @@ void randomSeed(uint16_t seed);
#endif
#endif
#endif // RANDOM_H

View file

@ -21,7 +21,12 @@
*/
#include "sprite.h"
#ifndef WITHOUT_SPRITE
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_sprite.h"
#endif
#define OFF_SPR_ADL_L 1
@ -77,3 +82,6 @@ void spriteReset(void) {
// Hide all sprites.
for (x=0; x<64; x++) spriteSetVisible(x, false);
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef SPRITE_H
#define SPRITE_H
#ifndef WITHOUT_SPRITE
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void spriteDefine(byte s, uint32_t address, byte size, byte CLUT, byte layer);
@ -45,4 +48,5 @@ void spriteReset(void);
#endif
#endif
#endif // SPRITE_H

View file

@ -21,8 +21,13 @@
*/
#include "text.h"
#include "math.h"
#ifndef WITHOUT_TEXT
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_text.h"
#include "f_math.h"
#endif
colorT textColors[16] = {
@ -251,3 +256,6 @@ void textSetDouble(bool x, bool y) {
_MAX_COL = x ? 40 : 80;
_MAX_ROW = y ? 30 : 60;
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef TEXT_H
#define TEXT_H
#ifndef WITHOUT_TEXT
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
// Apple IIgs Colors, because that's how we roll.
@ -81,4 +84,5 @@ void textSetDouble(bool x, bool y);
#endif
#endif
#endif // TEXT_H

View file

@ -21,7 +21,12 @@
*/
#include "tile.h"
#ifndef WITHOUT_TILE
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f_tile.h"
#endif
static byte _tileSize[3];
@ -136,3 +141,6 @@ void tileReset(void) {
tileSetVisible(1, false);
tileSetVisible(2, false);
}
#endif

View file

@ -23,6 +23,7 @@
#ifndef TILE_H
#define TILE_H
#ifndef WITHOUT_TILE
#ifdef __cplusplus
@ -31,7 +32,9 @@ extern "C"
#endif
#ifndef F256LIB_AMALGAMATED_BUILD
#include "f256.h"
#endif
void tileDefineTileMap(byte t, uint32_t address, byte tileSize, uint16_t mapSizeX, uint16_t mapSizeY);
@ -46,4 +49,5 @@ void tileReset(void);
#endif
#endif
#endif // TILE_H