Updated api.h which was causing kernel events to be screwy.
This commit is contained in:
parent
1a2fc959c6
commit
496ef13a94
7 changed files with 240 additions and 223 deletions
3
README
3
README
|
@ -68,6 +68,9 @@ 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.
|
||||
|
||||
The image converter can also take a bitmap and slice it into 8x8, 16x16, 24x24,
|
||||
or 32x32 chunks for use as sprite data.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
========
|
||||
|
|
|
@ -129,18 +129,26 @@ void getInput(void) {
|
|||
static byte twoJoy = 0;
|
||||
static byte keyJoy = 0;
|
||||
|
||||
do {
|
||||
kernelCall(NextEvent);
|
||||
|
||||
if (kernelEventData.type != 0) {
|
||||
textPrintInt(kernelEventData.type);
|
||||
textPrint(" ");
|
||||
textPrintInt(kernelEvent(key.PRESSED));
|
||||
textPrint(" ");
|
||||
textPrintInt(kernelEvent(key.RELEASED));
|
||||
textPrint("\n");
|
||||
}
|
||||
|
||||
// Read real joysticks.
|
||||
if (kernelEvent(JOYSTICK)) {
|
||||
oneJoy = kernelEventData.joystick.joy0;
|
||||
twoJoy = kernelEventData.joystick.joy1;
|
||||
anyJoy = oneJoy | twoJoy | keyJoy;
|
||||
if (kernelEventData.type == kernelEvent(GAME)) {
|
||||
oneJoy = kernelEventData.game.game0;
|
||||
twoJoy = kernelEventData.game.game1;
|
||||
}
|
||||
|
||||
// Use keyboard as virtual joystick.
|
||||
// ***TODO*** This doesn't work worth a crap.
|
||||
if (kernelEvent(key.PRESSED)) {
|
||||
if (kernelEventData.type == kernelEvent(key.PRESSED)) {
|
||||
switch (kernelEventData.key.ascii) {
|
||||
case 'w':
|
||||
case 'W':
|
||||
|
@ -171,53 +179,43 @@ void getInput(void) {
|
|||
keyJoy |= JOY_BUTTON_3;
|
||||
break;
|
||||
}
|
||||
anyJoy = oneJoy | twoJoy | keyJoy;
|
||||
}
|
||||
if (kernelEvent(key.RELEASED)) {
|
||||
if (kernelEventData.type == kernelEvent(key.RELEASED)) {
|
||||
switch (kernelEventData.key.ascii) {
|
||||
case 'w':
|
||||
case 'W':
|
||||
keyJoy &= JOY_UP;
|
||||
keyJoy &= ~JOY_UP;
|
||||
break;
|
||||
case 'a':
|
||||
case 'A':
|
||||
keyJoy &= JOY_LEFT;
|
||||
keyJoy &= ~JOY_LEFT;
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
keyJoy &= JOY_DOWN;
|
||||
keyJoy &= ~JOY_DOWN;
|
||||
break;
|
||||
case 'd':
|
||||
case 'D':
|
||||
keyJoy &= JOY_RIGHT;
|
||||
keyJoy &= ~JOY_RIGHT;
|
||||
break;
|
||||
case 'j':
|
||||
case 'J':
|
||||
keyJoy &= JOY_BUTTON_1;
|
||||
keyJoy &= ~JOY_BUTTON_1;
|
||||
break;
|
||||
case 'k':
|
||||
case 'K':
|
||||
keyJoy &= JOY_BUTTON_2;
|
||||
keyJoy &= ~JOY_BUTTON_2;
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
keyJoy &= JOY_BUTTON_3;
|
||||
keyJoy &= ~JOY_BUTTON_3;
|
||||
break;
|
||||
anyJoy = oneJoy | twoJoy | keyJoy;
|
||||
}
|
||||
}
|
||||
} while (kernelGetPending() > 0);
|
||||
|
||||
/*
|
||||
textGotoXY(0, 0);
|
||||
textPrintInt(oneJoy);
|
||||
textPrint(" ");
|
||||
textPrintInt(twoJoy);
|
||||
textPrint(" ");
|
||||
textPrintInt(keyJoy);
|
||||
textPrint(" ");
|
||||
textPrintInt(anyJoy);
|
||||
textPrint(" ");
|
||||
*/
|
||||
// Merge inputs. Yes, this allows dumb things like LEFT and RIGHT at the same time.
|
||||
anyJoy = oneJoy | twoJoy | keyJoy;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -61,9 +61,9 @@ int main(void) {
|
|||
tileSetScroll(0, 0, xs, 0, ys);
|
||||
|
||||
while (true) {
|
||||
kernelEventData.type = 0;
|
||||
kernelCall(NextEvent);
|
||||
if (kernelGetPending() > 0) {
|
||||
if (kernelEvent(key.PRESSED)) {
|
||||
if (kernelEventData.type == kernelEvent(key.RELEASED)) {
|
||||
switch (kernelEventData.key.ascii) {
|
||||
case 'w':
|
||||
case 'W':
|
||||
|
@ -90,7 +90,6 @@ int main(void) {
|
|||
textPrint(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
174
f256lib/api.h
174
f256lib/api.h
|
@ -1,20 +1,15 @@
|
|||
/*
|
||||
* This file is part of the TinyCore MicroKernel for the Foenix F256,
|
||||
* Copyright 2022,2023 Jessie Oberreuter <Gadget@HackwrenchLabs.com>. As with
|
||||
* the Linux Kernel Exception to the GPL3, programs built to run on the
|
||||
* MicroKernel are expected to include this file. Doing so does not affect
|
||||
* their license status.
|
||||
* This file is part of the TinyCore 6502 MicroKernel, Copyright 2022 Jessie
|
||||
* Oberreuter <joberreu@moselle.com>. As with the Linux Kernel Exception to
|
||||
* the GPL3, programs built to run on the MicroKernel are expected to
|
||||
* include this file. Doing so does not effect their license status.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
/*
|
||||
* Kernel calls populate the kernel.arg.* variables appropriately, and then
|
||||
* Kernel Calls Populate the kernel.arg.* variables appropriately, and then
|
||||
* JSR to one of the velctors below:
|
||||
*/
|
||||
|
||||
#ifndef kernel_h
|
||||
#define kernel_h
|
||||
#ifndef kernel_api_h
|
||||
#define kernel_api_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -25,9 +20,9 @@ struct call { // Mount at $ff00
|
|||
long ReadExt; // Copy secondary bolk event data into user-space
|
||||
long Yield; // Give unused time to the kernel.
|
||||
long Putch; // deprecated
|
||||
long Basic; // deprecated
|
||||
long dummy1; // reserved
|
||||
long dummy2; // reserved
|
||||
long RunBlock; //
|
||||
long RunNamed; //
|
||||
long reserved;
|
||||
|
||||
struct {
|
||||
long List; // Returns a bit-set of available block-accessible devices.
|
||||
|
@ -57,43 +52,55 @@ struct call { // Mount at $ff00
|
|||
long Close; // Close an open file.
|
||||
long Rename; // Rename a closed file.
|
||||
long Delete; // Delete a closed file.
|
||||
long Seek; // Set the next read/write position within an open file.
|
||||
} File;
|
||||
|
||||
struct {
|
||||
long Open; // Open a directory for reading.
|
||||
long Read; // Read a directory entry; may also return VOLUME and FREE events.
|
||||
long Close; // Close a directory once finished reading.
|
||||
long MkDir; // Create a new directory.
|
||||
long RmDir; // Deletes an existing directory.
|
||||
} Directory;
|
||||
|
||||
long gate;
|
||||
|
||||
struct {
|
||||
long GetSize; // Returns rows/cols in kernel args.
|
||||
long DrawRow; // Draw text/color buffers left-to-right
|
||||
long DrawColumn; // Draw text/color buffers top-to-bottom
|
||||
} Display;
|
||||
|
||||
struct {
|
||||
long GetIP; // Get the local IP address.
|
||||
long SetIP; // Set the local IP address.
|
||||
long GetDNS; // Get the configured DNS IP address.
|
||||
long SetDNS; // Set the configured DNS IP address.
|
||||
long GetTime; //
|
||||
long SetTime; //
|
||||
long GetSysInfo; //
|
||||
long SetBPS; // Set the serial BPS (should match the SLIP router's speed).
|
||||
} Config;
|
||||
long SendICMP; // Send an ICMP packet (typically a ping).
|
||||
long Match; // Determine if the current event matches a specific socket.
|
||||
|
||||
struct {
|
||||
long InitUDP; //
|
||||
long SendUDP; //
|
||||
long RecvUDP; //
|
||||
long InitTCP; //
|
||||
long SendTCP; //
|
||||
long RecvTCP; //
|
||||
long SendICMP; //
|
||||
long RecvICMP; //
|
||||
} Net;
|
||||
long Init; // Initialize a 32 byte UDP socket structure.
|
||||
long Send; // Send data via the supplied UDP socket structure.
|
||||
long Recv; // Copy the UDP payload from the event to the user's address space.
|
||||
} UDP;
|
||||
|
||||
struct {
|
||||
long Open; // Initialize a 256 byte TCP structure for a specified destination.
|
||||
long Accept; // Initialize a 256 byte TCP structure from a received SYN packet.
|
||||
long Reject; // Reply to a received TCP packet with a REJECT message.
|
||||
long Send; // Accept some new data and send an ACK along with any unACK'd data.
|
||||
long Recv; // Copy any new TCP bytes into the user's buf and update the socket state.
|
||||
} TCP;
|
||||
};
|
||||
|
||||
struct {
|
||||
long Reset; // Re-init the display.
|
||||
long GetSize; // Returns rows/cols in kernel args.
|
||||
long DrawRow; // Draw text/color buffers left-to-right
|
||||
long DrawColumn; // Draw text/color buffers top-to-bottom
|
||||
} Display;
|
||||
|
||||
struct {
|
||||
long GetTime; // Get the date+time in BCD: YY,YY,MM,DD,HH,MM,SS,cS
|
||||
long SetTime; //
|
||||
long GetSysInfo; //
|
||||
long SetBPS; //
|
||||
} Config;
|
||||
};
|
||||
|
||||
// Kernel Call Arguments; mount at $f0
|
||||
|
@ -105,9 +112,9 @@ struct events_t {
|
|||
|
||||
struct common_t {
|
||||
char dummy[8-sizeof(struct events_t)];
|
||||
void * ext;
|
||||
const void * ext;
|
||||
uint8_t extlen;
|
||||
void * buf;
|
||||
const void * buf;
|
||||
uint8_t buflen;
|
||||
void * internal;
|
||||
};
|
||||
|
@ -169,6 +176,12 @@ struct fs_delete_t {
|
|||
// fname_len = args.buflen
|
||||
};
|
||||
|
||||
struct fs_seek_t {
|
||||
uint8_t streak;
|
||||
uint8_t cookie;
|
||||
uint32_t position;
|
||||
};
|
||||
|
||||
struct file_t {
|
||||
union {
|
||||
struct fs_open_t open;
|
||||
|
@ -177,6 +190,7 @@ struct file_t {
|
|||
struct fs_close_t close;
|
||||
struct fs_rename_t rename;
|
||||
struct fs_delete_t delete;
|
||||
struct fs_seek_t seek;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -201,6 +215,8 @@ struct dir_t {
|
|||
struct dir_open_t open;
|
||||
struct dir_read_t read;
|
||||
struct dir_close_t close;
|
||||
struct dir_open_t mkdir;
|
||||
struct dir_open_t rmdir;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -236,58 +252,68 @@ struct call_args {
|
|||
struct events {
|
||||
uint16_t reserved;
|
||||
uint16_t deprecated;
|
||||
uint16_t JOYSTICK; // joystick events
|
||||
uint16_t GAME; // joystick events
|
||||
uint16_t DEVICE; // deprecated
|
||||
|
||||
struct {
|
||||
uint8_t PRESSED;
|
||||
uint8_t RELEASED;
|
||||
uint16_t PRESSED;
|
||||
uint16_t RELEASED;
|
||||
} key;
|
||||
|
||||
struct {
|
||||
uint8_t DELTA;
|
||||
uint8_t CLICKS;
|
||||
uint16_t DELTA;
|
||||
uint16_t CLICKS;
|
||||
} mouse;
|
||||
|
||||
struct {
|
||||
uint8_t NAME;
|
||||
uint8_t SIZE;
|
||||
uint8_t DATA;
|
||||
uint8_t WROTE;
|
||||
uint8_t FORMATTED;
|
||||
uint8_t ERROR;
|
||||
uint16_t NAME;
|
||||
uint16_t SIZE;
|
||||
uint16_t DATA;
|
||||
uint16_t WROTE;
|
||||
uint16_t FORMATTED;
|
||||
uint16_t ERROR;
|
||||
} block;
|
||||
|
||||
struct {
|
||||
uint8_t SIZE;
|
||||
uint8_t CREATED;
|
||||
uint8_t CHECKED;
|
||||
uint8_t DATA;
|
||||
uint8_t WROTE;
|
||||
uint8_t ERROR;
|
||||
uint16_t SIZE;
|
||||
uint16_t CREATED;
|
||||
uint16_t CHECKED;
|
||||
uint16_t DATA;
|
||||
uint16_t WROTE;
|
||||
uint16_t ERROR;
|
||||
} fs;
|
||||
|
||||
struct {
|
||||
uint8_t NOT_FOUND;
|
||||
uint8_t OPENED;
|
||||
uint8_t DATA;
|
||||
uint8_t WROTE;
|
||||
uint8_t EOF;
|
||||
uint8_t CLOSED;
|
||||
uint8_t RENAMED;
|
||||
uint8_t DELETED;
|
||||
uint8_t ERROR;
|
||||
uint16_t NOT_FOUND;
|
||||
uint16_t OPENED;
|
||||
uint16_t DATA;
|
||||
uint16_t WROTE;
|
||||
uint16_t EOF;
|
||||
uint16_t CLOSED;
|
||||
uint16_t RENAMED;
|
||||
uint16_t DELETED;
|
||||
uint16_t ERROR;
|
||||
uint16_t SEEK;
|
||||
} file;
|
||||
|
||||
struct {
|
||||
uint8_t OPENED;
|
||||
uint8_t VOLUME;
|
||||
uint8_t FILE;
|
||||
uint8_t FREE;
|
||||
uint8_t EOF;
|
||||
uint8_t CLOSED;
|
||||
uint8_t ERROR;
|
||||
uint16_t OPENED;
|
||||
uint16_t VOLUME;
|
||||
uint16_t FILE;
|
||||
uint16_t FREE;
|
||||
uint16_t EOF;
|
||||
uint16_t CLOSED;
|
||||
uint16_t ERROR;
|
||||
} directory;
|
||||
|
||||
struct {
|
||||
uint16_t TCP;
|
||||
uint16_t UDP;
|
||||
} net;
|
||||
|
||||
struct {
|
||||
uint16_t TICK;
|
||||
} clock;
|
||||
};
|
||||
|
||||
|
||||
|
@ -318,9 +344,9 @@ struct event_mouse_t {
|
|||
};
|
||||
};
|
||||
|
||||
struct event_joystick_t {
|
||||
uint8_t joy0;
|
||||
uint8_t joy1;
|
||||
struct event_game_t {
|
||||
uint8_t game0;
|
||||
uint8_t game1;
|
||||
};
|
||||
|
||||
struct event_fs_data_t {
|
||||
|
@ -377,7 +403,7 @@ struct event_t {
|
|||
union {
|
||||
struct event_key_t key;
|
||||
struct event_mouse_t mouse;
|
||||
struct event_joystick_t joystick;
|
||||
struct event_game_t game;
|
||||
struct event_file_t file;
|
||||
struct event_dir_t directory;
|
||||
};
|
||||
|
|
|
@ -36,9 +36,8 @@ static byte _BITMAP_CLUT[3];
|
|||
static byte _color;
|
||||
static byte _active; // Current drawing page.
|
||||
|
||||
#define bitmapPutPixelIOSet(x, y) FAR_POKE((_BITMAP_BASE[_active] + mathUnsignedAddition(mathUnsignedMultiply(y, _MAX_X), (int32_t)x)), _color)
|
||||
|
||||
//static void bitmapPutPixelIOSet(uint16_t x, uint16_t y);
|
||||
#define bitmapPutPixelIOSet(x, y) FAR_POKE((_BITMAP_BASE[_active] + mathUnsignedAddition(mathUnsignedMultiply(y, _MAX_X), (int32_t)x)), _color)
|
||||
|
||||
|
||||
void bitmapClear(void) {
|
||||
|
@ -144,21 +143,6 @@ void bitmapPutPixel(uint16_t x, uint16_t y) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
// This does the actual pixel setting but depends on the I/O being umapped.
|
||||
static void bitmapPutPixelIOSet(uint16_t x, uint16_t y) {
|
||||
uint32_t pixelRAM;
|
||||
byte block;
|
||||
|
||||
pixelRAM = _BITMAP_BASE[_active] + mathUnsignedAddition(mathUnsignedMultiply(y, _MAX_X), (int32_t)x);
|
||||
block = pixelRAM / EIGHTK;
|
||||
pixelRAM &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
POKE(SWAP_ADDR + pixelRAM, _color);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void bitmapReset(void) {
|
||||
uint32_t realSize;
|
||||
uint32_t pageBlocks;
|
||||
|
@ -250,13 +234,13 @@ void bitmapSetColor(byte c) {
|
|||
void bitmapSetVisible(byte p, bool v) {
|
||||
switch (p) {
|
||||
case 0:
|
||||
POKE(VKY_BM0_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 0, GLUT 0.
|
||||
POKE(VKY_BM0_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 0.
|
||||
break;
|
||||
case 1:
|
||||
POKE(VKY_BM1_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 0, GLUT 0.
|
||||
POKE(VKY_BM1_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 1.
|
||||
break;
|
||||
case 2:
|
||||
POKE(VKY_BM2_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 0, GLUT 0.
|
||||
POKE(VKY_BM2_CTRL, v ? 1 | _BITMAP_CLUT[p] : 0); // Enable bitmap 2.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,10 +58,9 @@ typedef unsigned char bool;
|
|||
|
||||
// Our stuff.
|
||||
#define SWAP_SLOT MMU_MEM_BANK_5
|
||||
#define SWAP_ADDR ((uint16_t)(SWAP_SLOT - MMU_MEM_BANK_0) * (uint16_t)0x2000)
|
||||
|
||||
// This is an attempt to allow us to free up slot 5 and use slot 6 for paging
|
||||
// RAM in and out. Currently, it does not work.
|
||||
// RAM in and out. ***TODO*** Currently, it does not work.
|
||||
#if SWAP_SLOT == MMU_MEM_BANK_6
|
||||
|
||||
#define SWAP_IO_SETUP() \
|
||||
|
@ -78,6 +77,11 @@ typedef unsigned char bool;
|
|||
asm("cli"); \
|
||||
})
|
||||
|
||||
#elif SWAP_SLOT == MMU_MEM_BANK_7
|
||||
|
||||
#define SWAP_IO_SETUP() asm("sei");
|
||||
#define SWAP_IO_SHUTDOWN() asm("cli");
|
||||
|
||||
#else
|
||||
|
||||
#define SWAP_IO_SETUP()
|
||||
|
@ -85,6 +89,8 @@ typedef unsigned char bool;
|
|||
|
||||
#endif
|
||||
|
||||
#define SWAP_ADDR ((uint16_t)(SWAP_SLOT - MMU_MEM_BANK_0) * (uint16_t)0x2000)
|
||||
|
||||
|
||||
// Things not in the Merlin defs.
|
||||
#define TEXT_MATRIX 0xc000 // I/O Page 2
|
||||
|
|
|
@ -192,7 +192,6 @@ void textPrintUInt(uint32_t value){
|
|||
}
|
||||
|
||||
|
||||
// Reset display to text, "standard" colors.
|
||||
void textReset(void) {
|
||||
byte x;
|
||||
byte y;
|
||||
|
@ -239,6 +238,8 @@ void textSetCursor(byte c) {
|
|||
|
||||
|
||||
void textSetDouble(bool x, bool y) {
|
||||
//***TODO*** Adding this function seems to have screwed up scrolling.
|
||||
|
||||
POKE(VKY_MSTR_CTRL_1, (PEEK(VKY_MSTR_CTRL_1) & 0xf9) | (x << 1) | (y << 2));
|
||||
|
||||
_MAX_COL = x ? 40 : 80;
|
||||
|
|
Loading…
Add table
Reference in a new issue