defalte testing

This commit is contained in:
optixx
2009-11-02 07:48:19 +01:00
parent 5a439f56bb
commit e3cc6f41e2
7 changed files with 1242 additions and 874 deletions

View File

@@ -1,3 +1,6 @@
MD5=md5
all:
gcc -c loader_test.c
gcc -c inflate.c
@@ -10,7 +13,7 @@ loader:
test:
./inflate_test
@md5sum out.smc
@md5sum out_ref.smc
@md5sum ../../roms/qd16boot02_half.smc
@$(MD5) out.smc
@$(MD5) out_ref.smc
@$(MD5) ../../roms/qd16boot02_half.smc

View File

@@ -73,7 +73,7 @@ void neginf_cb_copy(nsize from, nsize to, nint length)
if ((to - from) < ( 1024 * 2 ) ){
cnt_hit++;
}
printf("neginf_cb_copy from=0x%06x to=0x%06x dist=%i len=%i\n",from, to, (to - from), length);
printf("neginf_cb_copy from=0x%06x to=0x%06x dist=%i len=%i\n",(int)from, (int)to, (int)(to - from), (int)length);
for (i=0; i<length;i++){
mem_ref[to+i] = mem_ref[from+i];
}
@@ -81,3 +81,5 @@ void neginf_cb_copy(nsize from, nsize to, nint length)
}

View File

@@ -27,6 +27,7 @@
extern const char _rom[];
extern char inflate_done;
int main(int argc, char **argv)
{
@@ -40,4 +41,4 @@ int main(int argc, char **argv)
neginf_process_byte(0x00);
inflate_flush();
return 0;
}
}

View File

@@ -13,14 +13,9 @@ b-> x
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "ringbuffer.h"
#define ringbuffer_size 2048
#define memory_size 65536
#define t &buf[ringbuffer_size - 1]
#define b &buf[0]
@@ -36,20 +31,30 @@ int pos_head;
char *r; // position from where we can read (if rb_count > 0)
char *w; // next free position (if rb_count < ringbuffer_size))
char *o; // output pointer
void rb_init()
{
r = b;
w = b;
o = b;
rb_count = 0;
memory = (char*)malloc(memory_size);
pos_mem = 0;
pos_head = 0;
}
void rb_dump()
{
int i;
printf("b=0x%02x t=0x%02x w=0x%02x o=0x%02x\n",*b,*t,*w,*o);
for (i=0; i<ringbuffer_size; i++)
printf("%02i 0x%02x\n",i, buf[i]);
}
void rb_flush(){
FILE *file;
while(!rb_isempty()){
memory[pos_mem++] = rb_get();
}
@@ -61,32 +66,61 @@ void rb_flush(){
char rb_get(void)
{
rb_count--;
if (r > t)
r = b;
return *r++;
rb_count--;
if (r > t)
r = b;
return *r++;
}
char rb_read(void)
char rb_read(int pos)
{
if (r > t) r = b;
return *r++;
char *p;
printf("rb_read: pos_mem=%06i pos_head=%06i pos=%06i\n",
pos_mem, pos_head,pos);
if ( pos_head - pos > ringbuffer_size){
printf("rb_read: memory[%i]=0x%02x \n",
pos,
memory[pos]);
return memory[pos];
}
if (w - index >= b)
p = w - index;
else
p = b + (b - ( w - index ));
return *p;
}
void rb_copy(int from,int to,int len){
int i;
char c;
for (i = from; i< to; i++){
c = rb_read(i);
rb_put(c);
}
}
void rb_put(char el)
{
pos_head++;
rb_count++;
pos_head++;
rb_count++;
if ( rb_count > ringbuffer_size)
memory[pos_mem++]=el;
if ( rb_count > ringbuffer_size){
rb_dump();
memory[pos_mem++]=*o++;
if (o > t){
o = b;
}
}
printf("rb_count=%i pos_head=0x%06x add_mem=0x%06x\n",rb_count, pos_head,pos_mem);
printf("rb_count=%i pos_head=0x%06x add_mem=0x%06x\n",rb_count, pos_head,pos_mem);
if (w > t){
if (w > t){
w = b;
}
*w++ = el;
}
*w++ = el;
}

View File

@@ -3,7 +3,7 @@
#define _RING_BUFFER_H_
#define ringbuffer_size 32
#define ringbuffer_size 8
extern int rb_count;

File diff suppressed because it is too large Load Diff