-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
183 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* $PSLibId: Runtime Library Version 3.5$ */ | ||
#ifndef _LIBETC_H_ | ||
#define _LIBETC_H_ | ||
|
||
/* | ||
* (C) Copyright 1993/1994 Sony Corporation,Tokyo,Japan. All Rights Reserved | ||
* | ||
* libetc.h: Pad Interface | ||
*/ | ||
extern int PadIdentifier; | ||
/* | ||
* PAD I/O (SIO Pad) | ||
*/ | ||
#define PADLup (1<<12) | ||
#define PADLdown (1<<14) | ||
#define PADLleft (1<<15) | ||
#define PADLright (1<<13) | ||
#define PADRup (1<< 4) | ||
#define PADRdown (1<< 6) | ||
#define PADRleft (1<< 7) | ||
#define PADRright (1<< 5) | ||
#define PADi (1<< 9) | ||
#define PADj (1<<10) | ||
#define PADk (1<< 8) | ||
#define PADl (1<< 3) | ||
#define PADm (1<< 1) | ||
#define PADn (1<< 2) | ||
#define PADo (1<< 0) | ||
#define PADh (1<<11) | ||
#define PADL1 PADn | ||
#define PADL2 PADo | ||
#define PADR1 PADl | ||
#define PADR2 PADm | ||
#define PADstart PADh | ||
#define PADselect PADk | ||
|
||
#define MOUSEleft (1<<3) | ||
#define MOUSEright (1<<2) | ||
|
||
/* | ||
* PAD utility macro: _PAD(x,y) | ||
* x: controller ID (0 or 1) | ||
* y: PAD assign macro | ||
* | ||
* Example: _PAD(0,PADstart) ... PADstart of controller 1 | ||
* _PAD(1,PADLup) ... PADLup of controller 2 | ||
*/ | ||
#define _PAD(x,y) ((y)<<((x)<<4)) | ||
|
||
/* scratch pad address 0x1f800000 - 0x1f800400 */ | ||
#define getScratchAddr(offset) ((u_long *)(0x1f800000+offset*4)) | ||
|
||
/* | ||
* Video Mode: NTSC/PAL | ||
*/ | ||
#define MODE_NTSC 0 | ||
#define MODE_PAL 1 | ||
|
||
/* | ||
* Prototypes | ||
*/ | ||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) | ||
extern "C" { | ||
#endif | ||
int CheckCallback(void) ; | ||
void PadInit(int mode); | ||
int ResetCallback(void) ; | ||
int RestartCallback(void) ; | ||
int StopCallback(void) ; | ||
int VSync(int mode); | ||
int VSyncCallback(void (*f)()) ; | ||
int VSyncCallbacks(int ch, void (*f)()) ; | ||
long GetVideoMode (void); | ||
long SetVideoMode (long mode); | ||
u_long PadRead(int id); | ||
void PadStop(void); | ||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus) | ||
} | ||
#endif | ||
#endif /* _LIBETC_H_ */ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "../types.h" | ||
|
||
typedef void (*Callback)(); | ||
|
||
void trapIntrVSync(void); | ||
void setIntrVSync(int index, Callback callback); | ||
void memclr(int*, int); | ||
|
||
extern void InterruptCallback(int, void*); | ||
static Callback D_8002D354[8] = { | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL, | ||
NULL | ||
}; | ||
volatile int Vcount = 0; | ||
static volatile u_long* D_8002D378 = 0x1F801114; /* 0x1F801114 - Timer 1 Counter Mode */ | ||
|
||
void* startIntrVSync(void) { | ||
*D_8002D378 = 0x107; | ||
Vcount = 0; | ||
memclr(&D_8002D354, 8); | ||
InterruptCallback(0, &trapIntrVSync); | ||
return &setIntrVSync; | ||
} | ||
|
||
static void trapIntrVSync(void) { | ||
int i; | ||
|
||
Vcount += 1; | ||
(void)Vcount; | ||
|
||
for (i = 0; i < 8; i++) { | ||
if (D_8002D354[i] != NULL) { | ||
D_8002D354[i](); | ||
} | ||
} | ||
} | ||
|
||
static void setIntrVSync(int index, Callback callback) { | ||
if (callback != D_8002D354[index]) { | ||
D_8002D354[index] = callback; | ||
} | ||
} | ||
|
||
static void memclr(int* ptr, int size) { | ||
int i; | ||
int* e = ptr; | ||
|
||
for (i = size - 1; i != -1; i--) { | ||
*e = 0; | ||
e++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include "../types.h" | ||
#include <LIBETC.H> | ||
|
||
int PadIdentifier; | ||
static int pad_buf; | ||
|
||
void PadInit(int mode) { | ||
PadIdentifier = mode; | ||
pad_buf = -1; | ||
ResetCallback(); | ||
PAD_init(0x20000001, &pad_buf); | ||
ChangeClearPAD(0); | ||
} | ||
|
||
u_long PadRead(int id) { | ||
PAD_dr(); | ||
return ~pad_buf; | ||
} | ||
|
||
void PadStop(void) { StopPAD(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "../types.h" | ||
#include <LIBETC.H> | ||
|
||
static long D_8002D3A4 = 0; | ||
|
||
long SetVideoMode(long mode) { | ||
long prev; | ||
|
||
prev = D_8002D3A4; | ||
D_8002D3A4 = mode; | ||
return prev; | ||
} | ||
|
||
long GetVideoMode(void) { return D_8002D3A4; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters