added separate file for ...cookie() functions

This commit is contained in:
Markus Fröschle
2013-05-03 06:06:41 +00:00
parent 9fd2f28ec3
commit dc048978b5
3 changed files with 52 additions and 41 deletions

View File

@@ -15,6 +15,7 @@ APP=$(EMUSD).prg
all: $(APP)
SOURCES=$(EMUSD).c \
cookie.c \
xhdi.c
OBJECTS=$(SOURCES:.c=.o)

51
sd-emutos/cookie.c Normal file
View File

@@ -0,0 +1,51 @@
/*
* cookie.c
*
* Created on: 03.05.2013
* Author: mfro
*/
#include <stdint.h>
#include <osbind.h>
static uint32_t cookieptr(void)
{
return * (uint32_t *) 0x5a0L;
}
int getcookie(uint32_t cookie, uint32_t *p_value)
{
uint32_t *cookiejar = (long *) Supexec(cookieptr);
if (!cookiejar) return 0;
do
{
if (cookiejar[0] == cookie)
{
if (p_value) *p_value = cookiejar[1];
return 1;
}
else
cookiejar = &(cookiejar[2]);
} while (cookiejar[-2]);
return 0;
}
void setcookie(uint32_t cookie, uint32_t value)
{
uint32_t *cookiejar = (uint32_t *) Supexec(cookieptr);
do
{
if (cookiejar[0] == cookie)
{
cookiejar[1] = value;
return;
}
else
cookiejar = &(cookiejar[2]);
} while (cookiejar[-2]);
}

View File

@@ -19,47 +19,6 @@ typedef uint32_t (*cookie_fun)(uint16_t opcode,...);
static cookie_fun old_vector = NULL;
static long cookieptr (void)
{
return * (uint32_t *) 0x5a0L;
}
static int getcookie(uint32_t cookie, uint32_t *p_value)
{
long *cookiejar = (long *) Supexec (cookieptr);
if (!cookiejar) return 0;
do
{
if (cookiejar[0] == cookie)
{
if (p_value) *p_value = cookiejar[1];
return 1;
}
else
cookiejar = &(cookiejar[2]);
} while (cookiejar[-2]);
return 0;
}
static void setcookie(uint32_t cookie, uint32_t value)
{
long *cookiejar = (long *) Supexec(cookieptr);
do
{
if (cookiejar[0] == cookie)
{
cookiejar[1] = value;
return;
}
else
cookiejar = &(cookiejar[2]);
} while (cookiejar[-2]);
}
static cookie_fun get_fun_ptr(void)
{
static cookie_fun XHDI = NULL;