FIFO is now in C.
This commit is contained in:
parent
e368117a06
commit
abe8a5975a
desmume/src
|
@ -0,0 +1,61 @@
|
||||||
|
/* Copyright (C) 2006 yopyop
|
||||||
|
yopyop156@ifrance.com
|
||||||
|
yopyop156.ifrance.com
|
||||||
|
|
||||||
|
This file is part of DeSmuME
|
||||||
|
|
||||||
|
DeSmuME is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
DeSmuME is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with DeSmuME; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "FIFO.h"
|
||||||
|
|
||||||
|
void FIFOInit(FIFO * fifo)
|
||||||
|
{
|
||||||
|
unsigned long i;
|
||||||
|
|
||||||
|
fifo->begin = 0;
|
||||||
|
fifo->end = 0;
|
||||||
|
for(i = 0; i<0x2000; ++i)
|
||||||
|
fifo->data[i] = 0;
|
||||||
|
fifo->full = FALSE;
|
||||||
|
fifo->empty = TRUE;
|
||||||
|
fifo->error = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FIFOAdd(FIFO * fifo, unsigned long v)
|
||||||
|
{
|
||||||
|
if(fifo->full)
|
||||||
|
{
|
||||||
|
fifo->error = TRUE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fifo->data[fifo->end] = v;
|
||||||
|
fifo->end = (fifo->end + 1)& 0x1FFF;
|
||||||
|
fifo->full = (fifo->end == fifo->begin);
|
||||||
|
fifo->empty = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long FIFOValue(FIFO * fifo)
|
||||||
|
{
|
||||||
|
if(fifo->empty)
|
||||||
|
{
|
||||||
|
fifo->error = TRUE;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
unsigned long v = fifo->data[fifo->begin];
|
||||||
|
fifo->begin = (fifo->begin + 1)& 0x1FFF;
|
||||||
|
fifo->empty = (fifo->begin == fifo->end);
|
||||||
|
return v;
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* Copyright (C) 2006 yopyop
|
||||||
|
yopyop156@ifrance.com
|
||||||
|
yopyop156.ifrance.com
|
||||||
|
|
||||||
|
This file is part of DeSmuME
|
||||||
|
|
||||||
|
DeSmuME is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
DeSmuME is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with DeSmuME; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FIFO_H
|
||||||
|
#define FIFO_H
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
unsigned long data[0x2000];
|
||||||
|
unsigned long begin;
|
||||||
|
unsigned long end;
|
||||||
|
BOOL full;
|
||||||
|
BOOL empty;
|
||||||
|
BOOL error;
|
||||||
|
} FIFO;
|
||||||
|
|
||||||
|
void FIFOInit(FIFO * fifo);
|
||||||
|
void FIFOAdd(FIFO * fifo, unsigned long v);
|
||||||
|
unsigned long FIFOValue(FIFO * fifo);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -5,7 +5,7 @@ libdesmume_a_SOURCES = \
|
||||||
arm_instructions.cpp arm_instructions.hpp \
|
arm_instructions.cpp arm_instructions.hpp \
|
||||||
bios.cpp bios.hpp cp15.cpp cp15.hpp \
|
bios.cpp bios.hpp cp15.cpp cp15.hpp \
|
||||||
Disassembler.cpp Disassembler.hpp \
|
Disassembler.cpp Disassembler.hpp \
|
||||||
FIFO.cpp FIFO.hpp \
|
FIFO.c FIFO.h \
|
||||||
GPU.cpp GPU.hpp debug.c debug.h \
|
GPU.cpp GPU.hpp debug.c debug.h \
|
||||||
MMU.cpp MMU.hpp NDSSystem.cpp NDSSystem.hpp \
|
MMU.cpp MMU.hpp NDSSystem.cpp NDSSystem.hpp \
|
||||||
thumb_instructions.cpp thumb_instructions.hpp
|
thumb_instructions.cpp thumb_instructions.hpp
|
||||||
|
|
Loading…
Reference in New Issue