Moved Lines example into it's own project.

This commit is contained in:
Scott Duensing 2024-01-17 19:09:32 -06:00
parent 44bc230048
commit 0983eb73ab
9 changed files with 218 additions and 62 deletions

12
README
View file

@ -35,7 +35,7 @@ SCRIPTS
build-aesprite.sh - Downloads and builds the latest Aesprite.
build-header-tool.sh - Builds the included header tool. See below.
build-tools.sh - Builds the included header and image conversion tools.
build-llvm-mos.sh - Builds the latest llvm-mos toolchain.
@ -59,6 +59,16 @@ The included header tool allows you to add a KUP, PGX, or PGZ program header to
a raw binary generated by llvm-mos or Merlin. Look at the examples for samples.
IMAGE CONVERTER
===============
The image converter loads images of various formats and attempts to convert them
into a format usable by TinyVicky. It's not very smart. Images need to be the
proper size for your intended use and have 256 or fewer colors. The result of
the conversion will be a "clut" file with the color lookup table in it as well
as an "indexed" file of the pixels in your image mapped to the color table.
EXAMPLES
========

View file

@ -0,0 +1,50 @@
#
# 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.
#
# This is only to make my IDE happy.
# We can't actually build with it until I get llvm-mos integrated into
# toolchains. -- SCD
cmake_minimum_required(VERSION 3.22)
set(CMAKE_C_STANDARD 17)
project(lines)
set(DEFINES ${CMAKE_SOURCE_DIR}/../../include)
set(F256LIB ${CMAKE_SOURCE_DIR}/../../f256lib)
set(LINES_SOURCE
${F256LIB}/f256.h
${F256LIB}/f256.c
lines.c
)
add_executable(${CMAKE_PROJECT_NAME}
${LINES_SOURCE}
)
target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
${CMAKE_SOURCE_DIR}
${DEFINES}
${F256LIB}
)

52
examples/lines/build.sh Executable file
View file

@ -0,0 +1,52 @@
#!/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.
#
PROJECT=lines
START=0x200
F256=$(pwd)/../..
LLVM=${F256}/llvm-mos
SETTINGS=${LLVM}/mos-platform/f256k/lib/settings.ld
PATH=${LLVM}/bin:${PATH}
echo "__f256_start = ${START};" > ${SETTINGS}
CLANG="mos-f256k-clang -I${F256}/include -I${F256}/f256lib -O3"
${CLANG} -c ${F256}/f256lib/f256.c
${CLANG} -c ${PROJECT}.c
${CLANG} -o ${PROJECT} ${PROJECT}.o f256.o
mv -f ${PROJECT} ${PROJECT}.bin
${F256}/header/header \
pgz 24 \
${PROJECT}.pgz \
${START} \
${PROJECT}.bin ${START}
#llvm-nm ${PROJECT}.elf > ${PROJECT}.lst
llvm-objdump -d --print-imm-hex ${PROJECT}.elf > ${PROJECT}.lst
hexdump -C ${PROJECT}.pgz > ${PROJECT}.hex

View file

@ -0,0 +1,7 @@
[DEFAULT]
port=/dev/ttyUSB1
labels=sample.lbl
flash_address=380000
chunk_size=1024
cpu=65c02
data_rate=6000000

61
examples/lines/lines.c Normal file
View file

@ -0,0 +1,61 @@
/*
* 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.
*/
#include "f256.h"
int main(void) {
uint16_t x;
uint16_t y;
uint16_t x2;
uint16_t y2;
uint16_t mx;
uint16_t my;
byte l;
byte c = 0;
f256Init();
for (l=0; l<TEXTCOLORS_COUNT; l++) {
graphicsDefineColor(0, l, textColors[l].r, textColors[l].g, textColors[l].b);
}
bitmapSetColor(0);
bitmapClear();
bitmapSetVisible(0, true);
bitmapGetResolution(&mx, &my);
while (1) {
bitmapSetColor(c++);
if (c == TEXTCOLORS_COUNT) c = 0;
x = randomRead() % mx;
y = randomRead() % my;
x2 = randomRead() % mx;
y2 = randomRead() % my;
bitmapLine(x, y, x2, y2);
}
return 0;
}

26
examples/lines/run.sh Executable file
View file

@ -0,0 +1,26 @@
#!/bin/bash
#
# 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.
#
python ../../FoenixMgr/FoenixMgr/fnxmgr.py --run-pgz lines.pgz

View file

@ -24,57 +24,12 @@
#include "f256.h"
void bitmap(void);
void text(void);
void bitmap(void) {
uint16_t x;
uint16_t y;
uint16_t x2;
uint16_t y2;
uint16_t mx;
uint16_t my;
byte l;
byte c = 0;
// textPrint("\n");
for (l=0; l<TEXTCOLORS_COUNT; l++) {
graphicsDefineColor(0, l, textColors[l].r, textColors[l].g, textColors[l].b);
/*
textSetColor(l, 0);
textPrint("Color "); textPrintInt(l);
textPrint(" = R:"); textPrintInt(textColors[l].r);
textPrint(" G:"); textPrintInt(textColors[l].g);
textPrint(" B:"); textPrintInt(textColors[l].b);
textPrint("\n");
*/
}
bitmapSetColor(0);
bitmapClear();
bitmapSetVisible(0, true);
bitmapGetResolution(&mx, &my);
while (1) {
bitmapSetColor(c++);
if (c == TEXTCOLORS_COUNT) c = 0;
x = randomRead() % mx;
y = randomRead() % my;
x2 = randomRead() % mx;
y2 = randomRead() % my;
bitmapLine(x, y, x2, y2);
}
}
void text(void) {
int main(void) {
byte x;
byte y;
f256Init();
textPrint("F256 LIVES!\n");
textSetColor(LIGHT_GREEN, BLACK);
textPrint("Green!\n\n");
@ -96,12 +51,6 @@ void text(void) {
textPrintInt(kernelGetPending());
textPrint(" ");
}
}
int main(void) {
f256Init();
//text();
bitmap();
return 0;
}

View file

@ -59,9 +59,6 @@ void f256Init(void) {
tileReset();
spriteReset();
// Make font taller for us blind people.
textSetDouble(false, true);
randomSeed(0); //***TODO*** Use clock or something.
}

View file

@ -187,14 +187,15 @@ void textReset(void) {
byte x;
byte y;
_MAX_COL = 80;
_MAX_ROW = 30;
_fcolor = 15;
_bcolor = 0;
_ccolor = 240;
textSetCursor('_');
// Make font taller for us blind people.
textSetDouble(false, true);
// No cursor by default.
textSetCursor(0);
// Set up default text colors.
for (x=0; x<TEXTCOLORS_COUNT; x++)
@ -229,4 +230,7 @@ void textSetCursor(byte c) {
void textSetDouble(bool x, bool y) {
POKE(VKY_MSTR_CTRL_1, (PEEK(VKY_MSTR_CTRL_1) & 0xf9) | (x << 1) | (y << 2));
_MAX_COL = x ? 40 : 80;
_MAX_ROW = y ? 30 : 60;
}