Activate HeartBeat, and setup a pointer to the system Tick, for a 60hz tick timer

This commit is contained in:
dwsJason 2018-08-06 22:19:15 -04:00
parent 2e2effd3e5
commit 1c91c3903c
4 changed files with 52 additions and 4 deletions

View File

@ -172,6 +172,7 @@ extern void sysjoy_shutdown(void);
#ifdef IIGS
// GS Specific Stuff
extern int LZ4_Unpack(char* pDest, char* pPackedSource);
extern volatile unsigned long* tick;
#endif
#endif

View File

@ -293,7 +293,7 @@ frame(void)
while (1) {
{
printf("game_state = %s\n", game_state_strings[game_state]);
printf("%ld game_state = %s\n", *tick, game_state_strings[game_state]);
}

View File

@ -80,7 +80,7 @@ U32
sys_gettime(void)
{
#ifdef IIGS
return 0;
return tick[0] * 16;
#else
static U32 ticks_base = 0;
U32 ticks;

View File

@ -27,6 +27,7 @@
#include "debug.h"
#ifdef IIGS
#include <Event.h>
#include <GSOS.h>
#include <Memory.h>
#include <Orca.h>
@ -197,6 +198,24 @@ sysvid_chkvm(void)
#endif
}
#ifdef IIGS
volatile unsigned long* tick;
typedef struct
{
void* pLink;
Word Count;
Word Sig;
} taskHeader_t;
taskHeader_t dummyTask = {
0,
0,
0xA55A
};
#endif
/*
* Initialise video
*/
@ -205,6 +224,7 @@ sysvid_init(void)
{
#ifdef IIGS
handle hndl; // "generic memory handle"
void *directPageHandle;
// PushLong #0 ;/* Ask Shadowing Screen ($8000 bytes from $01/2000)*/
// PushLong #$8000
@ -246,16 +266,43 @@ sysvid_init(void)
printf("SUCCESS\n");
// Allocate Some Direct Page memory
//directPage = NewHandle( 0x200, userid(), 0xC005, 0 );
printf("Allocate Direct Page space 512 bytes\n");
directPageHandle = NewHandle( 0x200, userid(), 0xC005, 0 );
if (toolerror())
{
printf("Unable to allocate 512 bytes Direct Page\n");
printf("Game can't run\n");
sys_sleep(5000); // Wait 5 seconds
exit(1);
}
printf("SUCCESS\n");
//BlitFieldHndl = NewHandle(0x10000, userid(), 0xC014, 0);
sysvid_fb = (U8*)0x12000;
// SHR ON
*VIDEO_REGISTER|=0xC0;
//*VIDEO_REGISTER|=0xC0;
// ENABLE Shadowing of SHR
*SHADOW_REGISTER&=~0x08; // Shadow Enable
printf("MiscTool Startup\n");
MTStartUp(); // MiscTool Startup, for the Heartbeat
#if 0
printf("Event Manager Startup\n");
EMStartUp((Word)*directPageHandle,
(Word)0, // default 20
(Integer)0,
(Integer)320,
(Integer)0,
(Integer)200,
(Word)userid());
#endif
//printf("SetHeartBeat\n");
SetHeartBeat((pointer)&dummyTask); // Force the Tick Timer On
DelHeartBeat((pointer)&dummyTask); // Clear the dummy task from the list
// Address of GetTick internal tick variable
tick = (unsigned long*)GetAddr(tickCnt);
#endif
#ifndef IIGS