Working on bitmaps.

This commit is contained in:
Scott Duensing 2024-01-03 20:18:34 -06:00
parent 7f259eb824
commit 949258c1ab
23 changed files with 942 additions and 272 deletions

2
.gitignore vendored
View file

@ -25,6 +25,8 @@ llvm-mos/
llvm-mos-source/ llvm-mos-source/
llvm-mos-sdk-source/ llvm-mos-sdk-source/
FoenixMgr/ FoenixMgr/
FoenixIDE-source/
FoenixIDE/
depot_tools/ depot_tools/
skia/ skia/
aseprite/ aseprite/

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Jason Andersen
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.

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
if [[ ! -d depot_tools ]]; then if [[ ! -d depot_tools ]]; then
sudo apt-get install -y libgnutls28-dev libbz2-dev libharfbuzz-dev g++ cmake ninja-build libx11-dev libxcursor-dev libgl1-mesa-dev libfontconfig1-dev sudo apt-get install -y libgnutls28-dev libbz2-dev libharfbuzz-dev g++ cmake ninja-build libx11-dev libxcursor-dev libgl1-mesa-dev libfontconfig1-dev
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
pushd header pushd header
cc header.c -o header -lm cc header.c -o header -lm
popd popd

View file

@ -1,5 +1,28 @@
#!/bin/bash -e #!/bin/bash -e
#
# 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.
#
INSTALL=$(pwd)/llvm-mos INSTALL=$(pwd)/llvm-mos
if [[ "${1,,}" == "all" ]]; then if [[ "${1,,}" == "all" ]]; then
@ -9,14 +32,14 @@ if [[ "${1,,}" == "all" ]]; then
fi fi
pushd llvm-mos-source pushd llvm-mos-source
cmake \ cmake \
-C clang/cmake/caches/MOS.cmake \ -C clang/cmake/caches/MOS.cmake \
-G Ninja \ -G Ninja \
-S llvm \ -S llvm \
-B build \ -B build \
-DCMAKE_INSTALL_PREFIX=${INSTALL} -DCMAKE_INSTALL_PREFIX=${INSTALL}
cmake --build build cmake --build build
cmake --install build cmake --install build
popd popd
fi fi

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
PREFIX=$(pwd)/merlin32 PREFIX=$(pwd)/merlin32
if [[ ! -d merlin32-source ]]; then if [[ ! -d merlin32-source ]]; then

View file

@ -1,5 +1,28 @@
#!/bin/bash -ex #!/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.
#
F256=$(pwd)/../.. F256=$(pwd)/../..
LLVM=${F256}/llvm-mos LLVM=${F256}/llvm-mos
SETTINGS=${LLVM}/mos-platform/f256k/lib/settings.ld SETTINGS=${LLVM}/mos-platform/f256k/lib/settings.ld

View file

@ -1 +1,24 @@
/*
* 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.
*/
int main(void) { return 0; } int main(void) { return 0; }

View file

@ -1,3 +1,26 @@
#
# 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. # This is only to make my IDE happy.
# We can't actually build with it until I get llvm-mos integrated into # We can't actually build with it until I get llvm-mos integrated into
# toolchains. -- SCD # toolchains. -- SCD
@ -11,7 +34,6 @@ set(DEFINES ${CMAKE_SOURCE_DIR}/../../include)
set(F256LIB ${CMAKE_SOURCE_DIR}/../../f256lib) set(F256LIB ${CMAKE_SOURCE_DIR}/../../f256lib)
set(PGZTEST_SOURCE set(PGZTEST_SOURCE
${F256LIB}/api.h
${F256LIB}/f256.h ${F256LIB}/f256.h
${F256LIB}/f256.c ${F256LIB}/f256.c
pgztest.c pgztest.c

View file

@ -1,5 +1,28 @@
#!/bin/bash -ex #!/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.
#
F256=$(pwd)/../.. F256=$(pwd)/../..
LLVM=${F256}/llvm-mos LLVM=${F256}/llvm-mos
SETTINGS=${LLVM}/mos-platform/f256k/lib/settings.ld SETTINGS=${LLVM}/mos-platform/f256k/lib/settings.ld
@ -24,6 +47,6 @@ ${F256}/header/header \
${START} \ ${START} \
pgztest.bin ${START} pgztest.bin ${START}
#llvm-nm pgztest.elf #llvm-nm pgztest.elf > pgztest.lst
#llvm-objdump -d --print-imm-hex pgztest.elf llvm-objdump -d --print-imm-hex pgztest.elf > pgztest.lst
#hexdump -C pgztest.pgz hexdump -C pgztest.pgz > pgztest.hex

View file

@ -1,10 +1,40 @@
/*
* 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" #include "f256.h"
int main(void) { int main(void) {
reset(); f256Init();
/*
resetText();
print("F256 LIVES!\n"); print("F256 LIVES!\n");
setTextColor(LIGHT_GREEN, BLACK); setTextColor(LIGHT_GREEN, BLACK);
print("Green!"); print("Green!");
*/
resetGraphics();
return 0; return 0;
} }

View file

@ -1,5 +1,29 @@
#!/bin/bash #!/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 --boot FLASH #python ../../FoenixMgr/FoenixMgr/fnxmgr.py --boot FLASH
python ../../FoenixMgr/FoenixMgr/fnxmgr.py --run-pgz pgztest.pgz python ../../FoenixMgr/FoenixMgr/fnxmgr.py --run-pgz pgztest.pgz
#python ../../FoenixMgr/FoenixMgr/fnxmgr.py --dump 2000 --count 200 #python ../../FoenixMgr/FoenixMgr/fnxmgr.py --dump 10000 --count 10
#python ../../FoenixMgr/FoenixMgr/fnxmgr.py --copy pgztest.pgz #python ../../FoenixMgr/FoenixMgr/fnxmgr.py --copy pgztest.pgz

126
f256lib/bitmap.c Normal file
View file

@ -0,0 +1,126 @@
/*
* 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 "bitmap.h"
static int _MAX_X = 320;
static int _MAX_Y = 200;
static uint32_t _BITMAP_BASE = 0x10000;
static byte _color = 255;
char error;
void clear(void) {
int x;
int y;
//***TODO*** Use DMA
// This is just test code.
for (y=0; y<_MAX_Y; y++) {
for (x=0; x<_MAX_X; x++) {
putpixel(x, y);
}
_color++; // Let it roll over.
}
}
void defineGraphicsColor(byte slot, byte r, byte g, byte b) {
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
byte *write;
POKE(MMU_IO_CTRL, MMU_IO_PAGE_1); // Swap I/O page 1 into bank 6.
write = (byte *)VKY_GR_CLUT_0 + slot * 4;
*write++ = b;
*write++ = g;
*write++ = r;
*write++ = 0xff;
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
void putpixel(int x, int y) {
uint32_t pixelRAM;
byte block;
// We only map 8k of the bitmap into CPU RAM at once.
// We use slot 5 for this. We need to figure out
// where our pixel lands and bring that into RAM.
pixelRAM = _BITMAP_BASE + (y * _MAX_X) + x;
block = pixelRAM / 0x2000;
POKE(MMU_MEM_BANK_5, block);
//pixelRAM -= 0x2000 * block; // Find offset into this block.
pixelRAM &= 0x1FFF;
POKE(0xa000 + pixelRAM, _color);
POKE(MMU_MEM_BANK_5, 5);
}
void resetGraphics(void) {
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
byte x;
int y;
_MAX_X = 320;
_MAX_Y = 200;
_BITMAP_BASE = 0x10000;
_color = 255;
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
POKE(VKY_LAYER_CTRL_0, 16); // Bitmaps on all layers.
POKE(VKY_LAYER_CTRL_1, 1); // Bitmaps on all layers.
POKE(VKY_BM1_CTRL, 0); // Disable bitmap 1.
POKE(VKY_BM2_CTRL, 0); // Disable bitmap 2.
// Set up bitmap 0.
POKE(VKY_BM0_CTRL, 1); // Enable bitmap 0, GLUT 0.
//POKED(VKY_BM0_ADDR_L, _BITMAP_BASE); // Location of bitmap data.
POKE(VKY_BM0_ADDR_L, _BITMAP_BASE & 0xFF); // Location of bitmap data.
POKE(VKY_BM0_ADDR_M, (_BITMAP_BASE >> 8) & 0xFF); // Location of bitmap data.
POKE(VKY_BM0_ADDR_H, (_BITMAP_BASE >> 16) & 0xFF); // Location of bitmap data.
// Set palette to a gradient so there's at least *something*.
for (x=0; x<=255; x++) defineGraphicsColor(x, x, x, x);
clear();
/*
POKE(MMU_MEM_BANK_5, 8);
for (y=0; y<8192; y++) POKE(0xa000 + y, 255);
POKE(MMU_MEM_BANK_5, 5);
*/
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
void setGraphicsColor(byte c) {
_color = c;
}

49
f256lib/bitmap.h Normal file
View file

@ -0,0 +1,49 @@
/*
* 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.
*/
#ifndef BITMAP_H
#define BITMAP_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "f256.h"
void clear(void);
void defineGraphicsColor(byte slot, byte r, byte g, byte b);
void putpixel(int x, int y);
void resetGraphics(void);
void setGraphicsColor(byte c);
#ifdef __cplusplus
}
#endif
#endif // BITMAP_H

View file

@ -1,198 +1,52 @@
/*
* 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" #include "f256.h"
#include "text.c"
char error; #include "bitmap.c"
colorT textColors[16] = {
{ 0x00, 0x00, 0x00 }, // 0 Black
{ 0xdd, 0x00, 0x33 }, // 1 Deep Red
{ 0x00, 0x00, 0x99 }, // 2 Dark Blue
{ 0xdd, 0x22, 0xdd }, // 3 Purple
{ 0x00, 0x77, 0x22 }, // 4 Dark Green
{ 0x55, 0x55, 0x55 }, // 5 Dark Gray
{ 0x22, 0x22, 0xff }, // 6 Medium Blue
{ 0x66, 0xaa, 0xff }, // 7 Light Blue
{ 0x88, 0x55, 0x00 }, // 8 Brown
{ 0xff, 0x66, 0x00 }, // 9 Orange
{ 0xaa, 0xaa, 0xaa }, // A Light Gray
{ 0xff, 0x99, 0x88 }, // B Pink
{ 0x00, 0xdd, 0x00 }, // C Light Green
{ 0xff, 0xff, 0x00 }, // D Yellow
{ 0x55, 0xff, 0x99 }, // E Aquamarine
{ 0xff, 0xff, 0xff } // F White
};
static byte _MAX_COL = 80; void f256Init(void) {
static byte _MAX_ROW = 60; byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
static byte _row = 0;
static byte _col = 0;
static byte _fcolor = 15;
static byte _bcolor = 0;
static byte _ccolor = 240;
// Clear screen to current text attributes.
void cls(void) {
int i;
byte *vram = (byte *)TEXT_MATRIX;
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
for (i = 0; i < _MAX_COL * _MAX_ROW; i++) *vram++ = 32;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
vram = (byte *)TEXT_MATRIX;
for (i = 0; i < _MAX_COL * _MAX_ROW; i++) *vram++ = _ccolor;
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
gotoxy(0, 0);
}
// Define text color.
void defineTextColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb) {
byte mmu;
byte *write;
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
write = (byte *)VKY_TXT_FGLUT + slot * 4;
*write++ = fb;
*write++ = fg;
*write++ = fr;
*write++ = 0xff;
write = (byte *)VKY_TXT_BGLUT + slot * 4;
*write++ = bb;
*write++ = bg;
*write++ = br;
*write++ = 0xff;
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
// Move cursor.
void gotoxy(byte x, byte y) {
byte mmu;
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
_col = x;
POKE(VKY_CRSR_X_L, _col); // Set cursor X position.
POKE(VKY_CRSR_X_H, 0);
_row = y;
POKE(VKY_CRSR_Y_L, _row); // Set cursor Y position.
POKE(VKY_CRSR_Y_H, 0);
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
// Print a string to the screen.
void print(char *message) {
int x = 0;
int i = 0;
int j = 0;
byte *vram = (byte *)TEXT_MATRIX + _col + (_MAX_COL * _row);
byte *save = 0;
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
while (message[x] != 0) {
switch (message[x]) {
default:
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
vram[_col] = _ccolor;
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
vram[_col] = message[x];
_col++;
if (_col != _MAX_COL) break;
// Fall through.
case 10:
case 13:
_col = 0;
_row++;
if (_row == _MAX_ROW) {
// Scroll contents up one line.
vram = (byte *)TEXT_MATRIX;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
for (j=0; j<2; j++) {
for (i = 0; i < _MAX_COL * (_MAX_ROW - 1); i++) vram[i] = vram[i+_MAX_COL];
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
}
// Clear bottom line.
vram += i;
save = vram;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
for (i = 0; i < _MAX_COL; i++) *vram++ = _ccolor;
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
vram = save;
for (i = 0; i < _MAX_COL; i++) *vram++ = 32;
// Set up on bottom line.
_row--;
vram = (byte *)TEXT_MATRIX + _MAX_COL * (_MAX_ROW - 2) + 1;
break;
}
vram += _MAX_COL;
break;
}
x++;
}
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
gotoxy(_col, _row);
}
// Reset display to text, "standard" colors.
void reset(void) {
byte mmu;
byte x;
byte y;
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
// If we set 0xD000 to 0x01 and 0xD001 to 0x00, that will put us into text mode at 80 × 60.
POKE(VKY_MSTR_CTRL_0, 1);
POKE(VKY_MSTR_CTRL_1, 0);
_MAX_COL = 80;
_MAX_ROW = 60;
_fcolor = 15;
_bcolor = 0;
_ccolor = 240;
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6. POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
POKE(VKY_CRSR_CTRL, 3); // Enable cursor, 1/2s flash. POKE(VKY_MSTR_CTRL_0, 12); // Enable bitmaps.
POKE(VKY_CRSR_CHAR, '_'); // Set cursor shape. (199 = Checkerboard) //POKE(VKY_MSTR_CTRL_0, 15); // Enable text and bitmaps.
//POKE(VKY_MSTR_CTRL_0, 63); // Enable text and all graphics.
// Set up default text colors. POKE(VKY_MSTR_CTRL_1, 16); // Enable FON_OVLY.
for (x=0; x<TEXTCOLORS_COUNT; x++)
defineTextColor(x,
textColors[x].r,
textColors[x].g,
textColors[x].b,
textColors[x].r,
textColors[x].g,
textColors[x].b);
POKE(MMU_IO_CTRL, mmu); // Restore MMU state. POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
cls(); POKE(MMU_MEM_CTRL, 0xb3); // MLUT editing enabled, editing 3, 3 is active.
} // Set all memory slots to be CPU memory.
POKE(MMU_MEM_BANK_0, 0);
POKE(MMU_MEM_BANK_1, 1);
void setTextColor(byte f, byte b) { POKE(MMU_MEM_BANK_2, 2);
_fcolor = f; POKE(MMU_MEM_BANK_3, 3);
_bcolor = b; POKE(MMU_MEM_BANK_4, 4);
_ccolor = (f << 4) + b; POKE(MMU_MEM_BANK_5, 5);
// MMU_MEM_BANK_6 is always mapped to I/O.
// MMU_MEM_BANK_7 belongs to the MicroKernel.
} }

View file

@ -1,3 +1,26 @@
/*
* 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.
*/
#ifndef F256_H #ifndef F256_H
#define F256_H #define F256_H
@ -12,6 +35,7 @@ extern "C"
#include "stddclmr.h" #include "stddclmr.h"
#include "api.h" #include "api.h"
#include "f256_dma.h" #include "f256_dma.h"
#include "f256_intmath.h" #include "f256_intmath.h"
#include "f256_irq.h" #include "f256_irq.h"
@ -23,91 +47,36 @@ extern "C"
#include "f256_via.h" #include "f256_via.h"
#include "f256_xymath.h" #include "f256_xymath.h"
/*
#define MMU_MEM_CTRL 0x0000
#define MMU_IO_CTRL 0x0001
#define VICKY_MASTER_0 0xd000
#define VICKY_MASTER_1 0xd001
#define VICKY_GR_CLUT_0 0xd000 // I/O Page 1
#define VICKY_GR_CLUT_1 0xd400 // I/O Page 1
#define VICKY_GR_CLUT_2 0xd800 // I/O Page 1
#define VICKY_GR_CLUT_3 0xdc00 // I/O Page 1
*/
typedef unsigned char byte; typedef unsigned char byte;
#define TEXT_MATRIX 0xc000 // I/O Page 2
/*
#define TEXT_COLOR_MATRIX 0xc000 // I/O Page 3
#define TEXT_LUT_FOREGROUND 0xd800 // I/O Page 0
#define TEXT_LUT_BACKGROUND 0xd840 // I/O Page 0
#define TEXT_FONT_0 0xc000 // I/O Page 1
#define TEXT_FONT_1 0xc800 // I/O Page 1
#define CURSOR_SETTINGS 0xd010
#define CURSOR_CHARACTER 0xd012
#define CURSOR_X_LOW 0xd014
#define CURSOR_X_HIGH 0xd015
#define CURSOR_Y_LOW 0xd016
#define CURSOR_Y_HIGH 0xd017
*/
#define PEEK(addy) ((byte)*(volatile byte *)(addy)) #define PEEK(addy) ((byte)*(volatile byte *)(addy))
#define POKE(addy, value) (*(volatile byte *)(addy) = (value)) #define POKE(addy, value) (*(volatile byte *)(addy) = (value))
#define PEEKW(addy) ((uint_16)*(volatile uint16_t *)(addy))
#define POKEW(addy,value) (*(volatile uint16_t *)(addy) = (value))
#define PEEKD(addy) ((uint_32)*(volatile uint32_t *)(addy))
#define POKED(addy,value) (*(volatile uint32_t *)(addy) = (value))
#define VECTOR(member) (size_t)(&((struct call *)0xff00)->member) #define VECTOR(member) (size_t)(&((struct call *)0xff00)->member)
#define EVENT(member) (size_t)(&((struct events *)0)->member) #define EVENT(member) (size_t)(&((struct events *)0)->member)
#define CALL(fn) \ #define CALL(fn) \
asm("jsr %[addy] \n" \ asm("jsr %[addy] \n" \
"stz %[err] \n" \ "stz %[err] \n" \
"ror %[err]" \ "ror %[err]" \
: [err] "+m"(error) \ : [err] "+m"(error) \
: [addy] "i"(VECTOR(fn)) \ : [addy] "i"(VECTOR(fn)) \
: "a", "x", "y", "c", "v"); : "a", "x", "y", "c", "v");
extern struct event_t event; // The event struct is allocated in crt0. extern struct event_t event; // The event struct is allocated in crt0.
extern char error; extern char error;
// Apple IIgs Colors, because that's how we roll. void f256Init(void);
typedef enum textColorsE {
BLACK = 0,
DEEP_RED,
DARK_BLUE,
PURPLE,
DARK_GREEN,
DARK_GRAY,
MEDIUM_BLUE,
LIGHT_BLUE,
BROWN,
ORANGE,
LIGHT_GRAY,
PINK,
LIGHT_GREEN,
YELLOW,
AQUAMARINE,
WHITE,
TEXTCOLORS_COUNT
} textColorsT;
typedef struct colorS {
byte r;
byte g;
byte b;
} colorT;
extern colorT textColors[16];
void cls(void); #include "text.h"
void defineTextColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb); #include "bitmap.h"
void gotoxy(byte x, byte y);
void print(char *message);
void reset(void);
void setTextColor(byte f, byte b);
#ifdef __cplusplus #ifdef __cplusplus

214
f256lib/text.c Normal file
View file

@ -0,0 +1,214 @@
/*
* 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 "text.h"
char error;
colorT textColors[16] = {
{ 0x00, 0x00, 0x00 }, // 0 Black
{ 0xdd, 0x00, 0x33 }, // 1 Deep Red
{ 0x00, 0x00, 0x99 }, // 2 Dark Blue
{ 0xdd, 0x22, 0xdd }, // 3 Purple
{ 0x00, 0x77, 0x22 }, // 4 Dark Green
{ 0x55, 0x55, 0x55 }, // 5 Dark Gray
{ 0x22, 0x22, 0xff }, // 6 Medium Blue
{ 0x66, 0xaa, 0xff }, // 7 Light Blue
{ 0x88, 0x55, 0x00 }, // 8 Brown
{ 0xff, 0x66, 0x00 }, // 9 Orange
{ 0xaa, 0xaa, 0xaa }, // A Light Gray
{ 0xff, 0x99, 0x88 }, // B Pink
{ 0x00, 0xdd, 0x00 }, // C Light Green
{ 0xff, 0xff, 0x00 }, // D Yellow
{ 0x55, 0xff, 0x99 }, // E Aquamarine
{ 0xff, 0xff, 0xff } // F White
};
static byte _MAX_COL = 80;
static byte _MAX_ROW = 60;
static byte _row = 0;
static byte _col = 0;
static byte _fcolor = 15;
static byte _bcolor = 0;
static byte _ccolor = 240;
// Clear screen to current text attributes.
void cls(void) {
int i;
byte *vram = (byte *)TEXT_MATRIX;
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
for (i = 0; i < _MAX_COL * _MAX_ROW; i++) *vram++ = 32;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
vram = (byte *)TEXT_MATRIX;
for (i = 0; i < _MAX_COL * _MAX_ROW; i++) *vram++ = _ccolor;
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
gotoxy(0, 0);
}
// Define text color.
void defineTextColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb) {
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
byte *write;
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
write = (byte *)VKY_TXT_FGLUT + slot * 4;
*write++ = fb;
*write++ = fg;
*write++ = fr;
*write++ = 0xff;
write = (byte *)VKY_TXT_BGLUT + slot * 4;
*write++ = bb;
*write++ = bg;
*write++ = br;
*write++ = 0xff;
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
// Move cursor.
void gotoxy(byte x, byte y) {
byte mmu;
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
_col = x;
POKE(VKY_CRSR_X_L, _col); // Set cursor X position.
POKE(VKY_CRSR_X_H, 0);
_row = y;
POKE(VKY_CRSR_Y_L, _row); // Set cursor Y position.
POKE(VKY_CRSR_Y_H, 0);
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
}
// Print a string to the screen.
void print(char *message) {
int x = 0;
int i = 0;
int j = 0;
byte *vram = (byte *)TEXT_MATRIX + _col + (_MAX_COL * _row);
byte *save = 0;
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
while (message[x] != 0) {
switch (message[x]) {
default:
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
vram[_col] = _ccolor;
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
vram[_col] = message[x];
_col++;
if (_col != _MAX_COL) break;
// Fall through.
case 10:
case 13:
_col = 0;
_row++;
if (_row == _MAX_ROW) {
// Scroll contents up one line.
vram = (byte *)TEXT_MATRIX;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
for (j=0; j<2; j++) {
for (i = 0; i < _MAX_COL * (_MAX_ROW - 1); i++) vram[i] = vram[i+_MAX_COL];
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
}
// Clear bottom line.
vram += i;
save = vram;
POKE(MMU_IO_CTRL, MMU_IO_COLOR); // Swap I/O page 3 into bank 6.
for (i = 0; i < _MAX_COL; i++) *vram++ = _ccolor;
POKE(MMU_IO_CTRL, MMU_IO_TEXT); // Swap I/O page 2 into bank 6.
vram = save;
for (i = 0; i < _MAX_COL; i++) *vram++ = 32;
// Set up on bottom line.
_row--;
vram = (byte *)TEXT_MATRIX + _MAX_COL * (_MAX_ROW - 2) + 1;
break;
}
vram += _MAX_COL;
break;
}
x++;
}
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
gotoxy(_col, _row);
}
// Reset display to text, "standard" colors.
void resetText(void) {
byte mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
byte x;
byte y;
_MAX_COL = 80;
_MAX_ROW = 60;
_fcolor = 15;
_bcolor = 0;
_ccolor = 240;
POKE(MMU_IO_CTRL, MMU_IO_PAGE_0); // Swap I/O page 0 into bank 6.
POKE(VKY_CRSR_CTRL, 3); // Enable cursor, 1/2s flash.
POKE(VKY_CRSR_CHAR, '_'); // Set cursor shape. (199 = Checkerboard)
// Set up default text colors.
for (x=0; x<TEXTCOLORS_COUNT; x++)
defineTextColor(x,
textColors[x].r,
textColors[x].g,
textColors[x].b,
textColors[x].r,
textColors[x].g,
textColors[x].b);
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
cls();
}
void setTextColor(byte f, byte b) {
_fcolor = f;
_bcolor = b;
_ccolor = (f << 4) + b;
}

83
f256lib/text.h Normal file
View file

@ -0,0 +1,83 @@
/*
* 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.
*/
#ifndef TEXT_H
#define TEXT_H
#ifdef __cplusplus
extern "C"
{
#endif
#include "f256.h"
#define TEXT_MATRIX 0xc000 // I/O Page 2
// Apple IIgs Colors, because that's how we roll.
typedef enum textColorsE {
BLACK = 0,
DEEP_RED,
DARK_BLUE,
PURPLE,
DARK_GREEN,
DARK_GRAY,
MEDIUM_BLUE,
LIGHT_BLUE,
BROWN,
ORANGE,
LIGHT_GRAY,
PINK,
LIGHT_GREEN,
YELLOW,
AQUAMARINE,
WHITE,
TEXTCOLORS_COUNT
} textColorsT;
typedef struct colorS {
byte r;
byte g;
byte b;
} colorT;
extern colorT textColors[16];
void cls(void);
void defineTextColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb);
void gotoxy(byte x, byte y);
void print(char *message);
void resetText(void);
void setTextColor(byte f, byte b);
#ifdef __cplusplus
}
#endif
#endif // TEXT_H

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
if [[ ! -d FoenixMgr ]]; then if [[ ! -d FoenixMgr ]]; then
sudo apt-get install -y pip sudo apt-get install -y pip
git clone https://github.com/pweingar/FoenixMgr.git git clone https://github.com/pweingar/FoenixMgr.git

View file

@ -1,3 +1,26 @@
/*
* 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 <arpa/inet.h> #include <arpa/inet.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
BIN=$(pwd)/intelFPGA_lite/23.1std/quartus/bin BIN=$(pwd)/intelFPGA_lite/23.1std/quartus/bin
${BIN}/jtagconfig ${BIN}/jtagconfig

View file

@ -1,5 +1,28 @@
#!/bin/bash -ex #!/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.
#
INC=$(pwd)/include INC=$(pwd)/include
mkdir -p ${INC} mkdir -p ${INC}
@ -12,7 +35,7 @@ else
fi fi
pushd merlin-code/merlin32/jr pushd merlin-code/merlin32/jr
for FILE in $(ls *.asm); do for FILE in $(ls *.asm); do
HEADER=${INC}/$(basename ${FILE} .asm).h HEADER=${INC}/$(basename ${FILE} .asm).h
BLOCK=_$(basename ${FILE^^} .ASM)_H_ BLOCK=_$(basename ${FILE^^} .ASM)_H_
echo "#ifndef ${BLOCK}" > ${HEADER} echo "#ifndef ${BLOCK}" > ${HEADER}
@ -24,5 +47,5 @@ pushd merlin-code/merlin32/jr
sed 's/\(^[[:alpha:]].*$\)/#define \1/' >> ${HEADER} sed 's/\(^[[:alpha:]].*$\)/#define \1/' >> ${HEADER}
echo >> ${HEADER} echo >> ${HEADER}
echo "#endif // ${BLOCK}" >> ${HEADER} echo "#endif // ${BLOCK}" >> ${HEADER}
done done
popd popd

View file

@ -1,5 +1,28 @@
#!/bin/bash #!/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.
#
if [[ ! -d f256-firmware ]]; then if [[ ! -d f256-firmware ]]; then
git clone https://github.com/FoenixRetro/f256-firmware.git git clone https://github.com/FoenixRetro/f256-firmware.git
else else