o add io test

This commit is contained in:
David Voswinkel
2009-05-31 17:22:24 +02:00
parent d69d2bf398
commit 2fd08d0df7
20 changed files with 1314 additions and 37 deletions

View File

@@ -1,20 +1,33 @@
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include "data.h"
#include "pad.h"
#include "PPU.h"
#include "ressource.h"
word debugMap[0x400];
static char debug_buffer[255];
char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
void debug_init(void) {
word i;
for(i=0; i<0x400; i++) {
debugMap[i] = 0x00;
}
memset(debug_buffer,0,255);
}
void debug_enable(void){
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
VRAMLoad((word) debugMap, 0x4000, 0x0800);
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
setCharacterLocation(0x5000, (byte) 0);
*(byte*) 0x2100 = 0x0f; // enable background
}
char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
void int2hex(unsigned long number, char *buf,word size)
{
@@ -30,6 +43,8 @@ void int2hex(unsigned long number, char *buf,word size)
}
void print_screen(char *buffer,word y){
char i;
char l;
@@ -43,16 +58,55 @@ void print_screen(char *buffer,word y){
}
}
void print_console(char *buffer){
while(*buffer)
*(byte*) 0x3000=*buffer++;
}
void debug_enable(void){
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16);
VRAMLoad((word) debugMap, 0x4000, 0x0800);
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
setCharacterLocation(0x5000, (byte) 0);
*(byte*) 0x2100 = 0x0f; // enable background
}
void printfc(char *fmt, ...){
va_list arg;
va_start(arg,fmt);
vsprintf(debug_buffer,fmt,arg);
print_console(debug_buffer);
}
/* keep the linker happy */
int open(const char * _name, int _mode){
print_console("open called\n");
return -1;
}
int close(int fd){
print_console("close called\n");
return -1;
}
size_t read(int fd, void * buff, size_t len){
print_console("read called\n");
return 0;
}
size_t write(int fd, void * buffer, size_t len){
print_console("write called\n");
return 0;
}
long lseek(int fd, long off, int count){
print_console("lseek called\n");
return 0;
}
int unlink(const char * name){
print_console("unlink called\n");
return -1;
}
int isatty(){
print_console("isatty called\n");
return 1;
}