Various fixes.
This commit is contained in:
parent
400b35cd25
commit
9415a2ebc2
10 changed files with 59 additions and 17 deletions
|
@ -68,15 +68,19 @@ void dirtest(void) {
|
|||
|
||||
|
||||
int main(void) {
|
||||
struct time_t clock;
|
||||
|
||||
f256Init();
|
||||
|
||||
//dirtest();
|
||||
|
||||
while(true) {
|
||||
kernelNextEvent();
|
||||
kernelArgs->common.buf = &clock;
|
||||
kernelArgs->common.buflen = sizeof(struct time_t);
|
||||
kernelCall(Clock.GetTime);
|
||||
textGotoXY(0, 0);
|
||||
printf("%d.%d ", kernelArgs->time.seconds, kernelArgs->time.centis);
|
||||
printf("%d.%d ", clock.seconds, clock.centis);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -287,7 +287,6 @@ struct call_args {
|
|||
struct display_t display;
|
||||
struct net_t net;
|
||||
struct timer_t timer;
|
||||
struct time_t time;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -61,10 +61,7 @@ void f256Init(void) {
|
|||
tileReset();
|
||||
spriteReset();
|
||||
fileReset();
|
||||
|
||||
//***TODO*** The clock stuff doesn't actually work.
|
||||
kernelCall(Clock.GetTime);
|
||||
randomSeed(kernelArgs->time.centis);
|
||||
randomReset();
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,6 +82,22 @@ byte FAR_PEEK(uint32_t address) {
|
|||
}
|
||||
|
||||
|
||||
uint16_t FAR_PEEKW(uint32_t address) {
|
||||
byte block;
|
||||
uint16_t result;
|
||||
|
||||
SWAP_IO_SETUP();
|
||||
|
||||
block = address / EIGHTK;
|
||||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
result = PEEKW(SWAP_ADDR + address);
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void FAR_POKE(uint32_t address, byte value) {
|
||||
byte block;
|
||||
|
@ -98,3 +111,18 @@ void FAR_POKE(uint32_t address, byte value) {
|
|||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void FAR_POKEW(uint32_t address, uint16_t value) {
|
||||
byte block;
|
||||
|
||||
SWAP_IO_SETUP();
|
||||
|
||||
block = address / EIGHTK;
|
||||
address &= 0x1FFF; // Find offset into this block.
|
||||
POKE(SWAP_SLOT, block);
|
||||
POKEW(SWAP_ADDR + address, value);
|
||||
|
||||
SWAP_IO_SHUTDOWN();
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ typedef struct colorS {
|
|||
#define LOW_BYTE(v) ((byte)(x))
|
||||
#define HIGH_BYTE(v) ((byte)(((uint16_t)(x)) >> 8))
|
||||
#define SWAP_NIBBLES(x) ((x & 0x0F) << 4 | (x & 0xF0) >> 4)
|
||||
#define SWAP_UINT16(x) (((x) >> 8) | ((x) << 8))
|
||||
#define CHECK_BIT(x, pos) (x & (1UL << pos))
|
||||
#define TOGGLE_BIT(x, pos) (x ^= (1U << pos))
|
||||
#define CLEAR_BIT(x, pos) (x &= (~(1U << pos)))
|
||||
|
@ -158,7 +159,9 @@ extern byte SOF;
|
|||
|
||||
void f256Init(void);
|
||||
byte FAR_PEEK(uint32_t address);
|
||||
uint16_t FAR_PEEKW(uint32_t address);
|
||||
void FAR_POKE(uint32_t address, byte value);
|
||||
void FAR_POKEW(uint32_t address, uint16_t value);
|
||||
|
||||
|
||||
#include "kernel.h"
|
||||
|
|
|
@ -105,10 +105,10 @@ int8_t fileMakeDir(char *dir) {
|
|||
}
|
||||
|
||||
|
||||
int16_t *fileOpen(char *fname, char *mode) {
|
||||
int16_t ret = 0;
|
||||
uint8_t *fileOpen(char *fname, char *mode) {
|
||||
uint8_t ret = 0;
|
||||
uint8_t m = 0; // Default to READ.
|
||||
int16_t *fd;
|
||||
uint8_t *fd;
|
||||
byte drive;
|
||||
char *c;
|
||||
|
||||
|
@ -132,7 +132,7 @@ int16_t *fileOpen(char *fname, char *mode) {
|
|||
kernelNextEvent();
|
||||
switch (kernelEventData.type) {
|
||||
case kernelEvent(file.OPENED):
|
||||
fd = (int16_t *)malloc(sizeof(int16_t));
|
||||
fd = (uint8_t *)malloc(sizeof(uint8_t));
|
||||
*fd = ret;
|
||||
return fd;
|
||||
case kernelEvent(file.NOT_FOUND):
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct fileDirEntS {
|
|||
void fileClose(uint8_t *fd);
|
||||
int8_t fileCloseDir(char *dir);
|
||||
int8_t fileMakeDir(char *dir);
|
||||
int16_t *fileOpen(char *fname, char *mode);
|
||||
uint8_t *fileOpen(char *fname, char *mode);
|
||||
char *fileOpenDir(char *name);
|
||||
int16_t fileRead(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd);
|
||||
fileDirEntT *fileReadDir(char *dir);
|
||||
|
@ -56,10 +56,6 @@ int8_t fileUnlink(char *name);
|
|||
int16_t fileWrite(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd);
|
||||
|
||||
|
||||
// mkdir
|
||||
// rmdir
|
||||
|
||||
|
||||
#define _DE_ISREG(t) (t == 0)
|
||||
#define _DE_ISDIR(t) (t == 1)
|
||||
#define _DE_ISLBL(t) (t == 2)
|
||||
|
@ -73,6 +69,7 @@ int16_t fileWrite(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd);
|
|||
#define DIR char
|
||||
#define dirent fileDirEntS
|
||||
#define FILE uint8_t
|
||||
#define fclose fileClose
|
||||
#define fopen fileOpen
|
||||
#define fread fileRead
|
||||
#define fseek fileSeek
|
||||
|
|
|
@ -58,7 +58,6 @@ typedef struct call_args kernelArgsT;
|
|||
|
||||
extern kernelEventT kernelEventData;
|
||||
extern kernelArgsT *kernelArgs;
|
||||
extern char kernelError;
|
||||
|
||||
|
||||
byte kernelGetPending(void);
|
||||
|
|
|
@ -35,7 +35,7 @@ extern "C"
|
|||
|
||||
|
||||
void __putchar(char c);
|
||||
int getchar(void);
|
||||
int getchar(void); // This is an int so llvm-mos finds it.
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -34,6 +34,17 @@ uint16_t randomRead(void) {
|
|||
}
|
||||
|
||||
|
||||
void randomReset(void) {
|
||||
struct time_t clock;
|
||||
|
||||
// Seed the random number generator from the clock.
|
||||
kernelArgs->common.buf = &clock;
|
||||
kernelArgs->common.buflen = sizeof(struct time_t);
|
||||
kernelCall(Clock.GetTime);
|
||||
randomSeed(mathUnsignedMultiply(clock.seconds, clock.centis));
|
||||
}
|
||||
|
||||
|
||||
void randomSeed(uint16_t seed) {
|
||||
POKEW(VKY_SEEDL, seed);
|
||||
POKE(VKY_RND_CTRL, 3); // Enable, load seed.
|
||||
|
|
|
@ -35,6 +35,7 @@ extern "C"
|
|||
|
||||
|
||||
uint16_t randomRead(void);
|
||||
void randomReset(void);
|
||||
void randomSeed(uint16_t seed);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue