I broke it.
This commit is contained in:
parent
c26d06f060
commit
d33b227a30
5 changed files with 124 additions and 52 deletions
6
examples/pgztest/foenixmgr.ini
Normal file
6
examples/pgztest/foenixmgr.ini
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[DEFAULT]
|
||||||
|
port=COM3
|
||||||
|
labels=sample.lbl
|
||||||
|
flash_address=380000
|
||||||
|
chunk_size=1024
|
||||||
|
cpu=65816
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
cls();
|
reset();
|
||||||
print("F256 LIVES!");
|
//print("F256 LIVES!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
2
examples/pgztest/run.sh
Executable file
2
examples/pgztest/run.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
python ../../FoenixMgr/FoenixMgr/fnxmgr.py --port /dev/ttyUSB1 --run-pgz pgztest.pgz
|
129
f256lib/f256.c
129
f256lib/f256.c
|
@ -3,63 +3,74 @@
|
||||||
|
|
||||||
char error;
|
char error;
|
||||||
|
|
||||||
|
uint32_t textColors[16] = {
|
||||||
#define MAX_COL 80
|
0xff000000, // 0 Black
|
||||||
#define MAX_ROW 60
|
0xffdd0033, // 1 Deep Red
|
||||||
|
0xff000099, // 2 Dark Blue
|
||||||
|
0xffdd22dd, // 3 Purple
|
||||||
|
0xff007722, // 4 Dark Green
|
||||||
|
0xff555555, // 5 Dark Gray
|
||||||
|
0xff2222ff, // 6 Medium Blue
|
||||||
|
0xff66aaff, // 7 Light Blue
|
||||||
|
0xff885500, // 8 Brown
|
||||||
|
0xffff6600, // 9 Orange
|
||||||
|
0xffaaaaaa, // A Light Gray
|
||||||
|
0xffff9988, // B Pink
|
||||||
|
0xff00dd00, // C Light Green
|
||||||
|
0xffffff00, // D Yellow
|
||||||
|
0xff55ff99, // E Aquamarine
|
||||||
|
0xffffffff // F White
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static char row = 0;
|
static byte _MAX_COL = 80;
|
||||||
static char col = 0;
|
static byte _MAX_ROW = 60;
|
||||||
static char *line = (char *)TEXT_MATRIX;
|
static byte _row = 0;
|
||||||
|
static byte _col = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Clear screen, do not change text attributes.
|
||||||
void cls(void) {
|
void cls(void) {
|
||||||
int i;
|
int i;
|
||||||
char *vram = (char *)TEXT_MATRIX;
|
char *vram = (byte *)TEXT_MATRIX;
|
||||||
unsigned char mmu;
|
byte mmu;
|
||||||
|
|
||||||
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||||
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||||
|
|
||||||
for (i = 0; i < 80*60; i++) {
|
for (i = 0; i < _MAX_COL*_MAX_ROW; i++) *vram++ = 32;
|
||||||
*vram++ = 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
row = col = 0;
|
|
||||||
line = (char *)TEXT_MATRIX;
|
|
||||||
|
|
||||||
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||||
|
|
||||||
POKE(CURSOR_SETTINGS, 9); // Disable cursor flash.
|
gotoxy(0, 0);
|
||||||
POKE(CURSOR_CHARACTER, '_'); // Set cursor shape.
|
}
|
||||||
|
|
||||||
POKE(CURSOR_X_LOW, col); // Set cursor X position.
|
|
||||||
|
// Move cursor.
|
||||||
|
void gotoxy(byte x, byte y) {
|
||||||
|
byte mmu;
|
||||||
|
|
||||||
|
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||||
|
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||||
|
|
||||||
|
_col = x;
|
||||||
|
POKE(CURSOR_X_LOW, _col); // Set cursor X position.
|
||||||
POKE(CURSOR_X_HIGH, 0);
|
POKE(CURSOR_X_HIGH, 0);
|
||||||
|
|
||||||
POKE(CURSOR_Y_LOW, row); // Set cursor Y position.
|
_row = y;
|
||||||
|
POKE(CURSOR_Y_LOW, _row); // Set cursor Y position.
|
||||||
POKE(CURSOR_Y_HIGH, 0);
|
POKE(CURSOR_Y_HIGH, 0);
|
||||||
|
|
||||||
POKE(0xd011, 0);
|
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void scroll() {
|
|
||||||
int i;
|
|
||||||
char *vram = (char *)TEXT_MATRIX;
|
|
||||||
|
|
||||||
for (i = 0; i < 80*59; i++) {
|
|
||||||
vram[i] = vram[i+80];
|
|
||||||
}
|
|
||||||
vram += i;
|
|
||||||
for (i = 0; i < 80; i++) {
|
|
||||||
*vram++ = 32;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Print a string to the screen.
|
||||||
void print(char *message) {
|
void print(char *message) {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
unsigned char mmu;
|
int i = 0;
|
||||||
|
char *vram = (byte *)TEXT_MATRIX + _col * _row;
|
||||||
|
byte mmu;
|
||||||
|
|
||||||
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||||
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||||
|
@ -67,22 +78,27 @@ void print(char *message) {
|
||||||
while (message[x] != 0) {
|
while (message[x] != 0) {
|
||||||
switch (message[x]) {
|
switch (message[x]) {
|
||||||
default:
|
default:
|
||||||
line[col] = message[x];
|
vram[_col] = message[x];
|
||||||
col++;
|
_col++;
|
||||||
if (col != MAX_COL) {
|
if (_col != _MAX_COL) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
// Fall through.
|
// Fall through.
|
||||||
case 10:
|
case 10:
|
||||||
case 13:
|
case 13:
|
||||||
col = 0;
|
_col = 0;
|
||||||
row++;
|
_row++;
|
||||||
if (row == MAX_ROW) {
|
if (_row == _MAX_ROW) {
|
||||||
scroll();
|
// Scroll contents up one line.
|
||||||
row--;
|
vram = (byte *)TEXT_MATRIX;
|
||||||
|
for (i = 0; i < _MAX_COL * (_MAX_ROW - 1); i++) vram[i] = vram[i+_MAX_COL];
|
||||||
|
// Clear bottom line.
|
||||||
|
vram += i;
|
||||||
|
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;
|
break;
|
||||||
}
|
}
|
||||||
line += 80;
|
vram += _MAX_COL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x++;
|
x++;
|
||||||
|
@ -90,6 +106,25 @@ void print(char *message) {
|
||||||
|
|
||||||
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||||
|
|
||||||
POKE(CURSOR_X_LOW, col);
|
POKE(CURSOR_X_LOW, _col);
|
||||||
POKE(CURSOR_Y_LOW, row);
|
POKE(CURSOR_Y_LOW, _row);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Reset display to text, "standard" colors.
|
||||||
|
void reset(void) {
|
||||||
|
byte mmu;
|
||||||
|
|
||||||
|
mmu = PEEK(MMU_IO_CTRL); // Get current MMU state.
|
||||||
|
POKE(MMU_IO_CTRL, 2); // Swap I/O page 2 into bank 6.
|
||||||
|
|
||||||
|
_MAX_COL = 80;
|
||||||
|
_MAX_ROW = 60;
|
||||||
|
|
||||||
|
POKE(CURSOR_SETTINGS, 9); // Disable cursor flash.
|
||||||
|
POKE(CURSOR_CHARACTER, '_'); // Set cursor shape.
|
||||||
|
|
||||||
|
POKE(MMU_IO_CTRL, mmu); // Restore MMU state.
|
||||||
|
|
||||||
|
cls();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ extern "C"
|
||||||
#define VICKY_GR_CLUT_3 0xdc00 // I/O Page 1
|
#define VICKY_GR_CLUT_3 0xdc00 // I/O Page 1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
typedef unsigned char byte;
|
||||||
|
|
||||||
|
|
||||||
#define TEXT_MATRIX 0xc000 // I/O Page 2
|
#define TEXT_MATRIX 0xc000 // I/O Page 2
|
||||||
#define TEXT_COLOR_MATRIX 0xc000 // I/O Page 3
|
#define TEXT_COLOR_MATRIX 0xc000 // I/O Page 3
|
||||||
#define TEXT_LUT_FOREGROUND 0xd800 // I/O Page 0
|
#define TEXT_LUT_FOREGROUND 0xd800 // I/O Page 0
|
||||||
|
@ -49,8 +53,8 @@ extern "C"
|
||||||
#define CURSOR_Y_LOW 0xd016
|
#define CURSOR_Y_LOW 0xd016
|
||||||
#define CURSOR_Y_HIGH 0xd017
|
#define CURSOR_Y_HIGH 0xd017
|
||||||
|
|
||||||
#define PEEK(addy) ((unsigned char)*(volatile unsigned char *)(addy))
|
#define PEEK(addy) ((byte)*(volatile byte *)(addy))
|
||||||
#define POKE(addy, value) (*(volatile unsigned char *)(addy) = (value))
|
#define POKE(addy, value) (*(volatile byte *)(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) \
|
||||||
|
@ -67,8 +71,33 @@ 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.
|
||||||
|
typedef enum textColorsE {
|
||||||
|
BLACK,
|
||||||
|
DEEP_RED,
|
||||||
|
DARK_BLUE,
|
||||||
|
PURPLE,
|
||||||
|
DARK_GREEN,
|
||||||
|
DARK_GRAY,
|
||||||
|
MEDIUM_BLUE,
|
||||||
|
LIGHT_BLUE,
|
||||||
|
BROWN,
|
||||||
|
ORANGE,
|
||||||
|
LIGHT_GRAY,
|
||||||
|
PINK,
|
||||||
|
LIGHT_GREEN,
|
||||||
|
YELLOW,
|
||||||
|
AQUAMARINE,
|
||||||
|
WHITE
|
||||||
|
} textColorsT;
|
||||||
|
|
||||||
|
extern uint32_t textColors[16];
|
||||||
|
|
||||||
|
|
||||||
void cls(void);
|
void cls(void);
|
||||||
|
void gotoxy(byte x, byte y);
|
||||||
void print(char *message);
|
void print(char *message);
|
||||||
|
void reset(void);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Add table
Reference in a new issue