addd bugs, clean code
This commit is contained in:
parent
4ea1912318
commit
1100333487
22
bugs/issue-032fab33a68ffbeb19f1e9fa4856101996759255.yaml
Normal file
22
bugs/issue-032fab33a68ffbeb19f1e9fa4856101996759255.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||
title: relocate code
|
||||
desc: |-
|
||||
move main code to upper page like 0xe4 and use 0x4f as shared mem window
|
||||
or even combine this
|
||||
code seems to reloacte and start, but ram doesn't seem accessable. broked
|
||||
sprintfs
|
||||
type: :bugfix
|
||||
component: fatfs
|
||||
release:
|
||||
reporter: David <david@optixx.org>
|
||||
status: :unstarted
|
||||
disposition:
|
||||
creation_time: 2009-06-10 14:22:10.400739 Z
|
||||
references: []
|
||||
|
||||
id: 032fab33a68ffbeb19f1e9fa4856101996759255
|
||||
log_events:
|
||||
- - 2009-06-10 14:22:11.288638 Z
|
||||
- David <david@optixx.org>
|
||||
- created
|
||||
- ""
|
||||
21
bugs/issue-6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6.yaml
Normal file
21
bugs/issue-6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||
title: "debug ram mapping "
|
||||
desc: |-
|
||||
global vars seem to be borked or miss used. seems all kind of buffers are overlapping
|
||||
just reordering global var order renders the code unusable.
|
||||
also the strange sprintf buffer conflicts seem to related to this issue
|
||||
type: :bugfix
|
||||
component: fatfs
|
||||
release:
|
||||
reporter: David <david@optixx.org>
|
||||
status: :unstarted
|
||||
disposition:
|
||||
creation_time: 2009-06-10 14:23:44.121219 Z
|
||||
references: []
|
||||
|
||||
id: 6498cae9de5e51829e5dbb6b8fcaa20c7a647aa6
|
||||
log_events:
|
||||
- - 2009-06-10 14:23:45.632999 Z
|
||||
- David <david@optixx.org>
|
||||
- created
|
||||
- ""
|
||||
20
bugs/issue-99ae09d1da472e76501325424bc586f78980199e.yaml
Normal file
20
bugs/issue-99ae09d1da472e76501325424bc586f78980199e.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
--- !ditz.rubyforge.org,2008-03-06/issue
|
||||
title: debug sta return val
|
||||
desc: |-
|
||||
debug the sta value in diskio.c
|
||||
never seems to take the correct value, looks like global,local scope problem
|
||||
type: :bugfix
|
||||
component: fatfs
|
||||
release:
|
||||
reporter: David <david@optixx.org>
|
||||
status: :unstarted
|
||||
disposition:
|
||||
creation_time: 2009-06-10 14:20:20.608109 Z
|
||||
references: []
|
||||
|
||||
id: 99ae09d1da472e76501325424bc586f78980199e
|
||||
log_events:
|
||||
- - 2009-06-10 14:20:24.343929 Z
|
||||
- David <david@optixx.org>
|
||||
- created
|
||||
- ""
|
||||
@ -3,78 +3,88 @@
|
||||
byte tileMapLocation[4];
|
||||
word characterLocation[4];
|
||||
|
||||
void waitForVBlank(void) {
|
||||
byte Status;
|
||||
do {
|
||||
Status = *(byte*)0x4210;
|
||||
} while (!(Status & 0x80));
|
||||
void waitForVBlank(void)
|
||||
{
|
||||
byte Status;
|
||||
do {
|
||||
Status = *(byte *) 0x4210;
|
||||
} while (!(Status & 0x80));
|
||||
}
|
||||
|
||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber) {
|
||||
tileMapLocation[bgNumber] = ((vramDst >> 8) & 0xfc) | ( screenProp & 0x03 );
|
||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||
void setTileMapLocation(word vramDst, byte screenProp, byte bgNumber)
|
||||
{
|
||||
tileMapLocation[bgNumber] = ((vramDst >> 8) & 0xfc) | (screenProp & 0x03);
|
||||
*(byte *) (0x2107 + bgNumber) = tileMapLocation[bgNumber];
|
||||
}
|
||||
|
||||
void restoreTileMapLocation(byte bgNumber) {
|
||||
*(byte*) (0x2107+bgNumber) = tileMapLocation[bgNumber];
|
||||
void restoreTileMapLocation(byte bgNumber)
|
||||
{
|
||||
*(byte *) (0x2107 + bgNumber) = tileMapLocation[bgNumber];
|
||||
}
|
||||
|
||||
void setCharacterLocation(word vramDst, byte bgNumber) {
|
||||
characterLocation[bgNumber] = vramDst;
|
||||
if(bgNumber < 2) {
|
||||
*(byte*) 0x210b = (characterLocation[1] >> 8 & 0xf0 ) + (characterLocation[0] >> 12);
|
||||
} else {
|
||||
*(byte*) 0x210c = (characterLocation[3] >> 8 & 0xf0 ) + (characterLocation[2] >> 12);
|
||||
}
|
||||
void setCharacterLocation(word vramDst, byte bgNumber)
|
||||
{
|
||||
characterLocation[bgNumber] = vramDst;
|
||||
if (bgNumber < 2) {
|
||||
*(byte *) 0x210b =
|
||||
(characterLocation[1] >> 8 & 0xf0) + (characterLocation[0] >> 12);
|
||||
} else {
|
||||
*(byte *) 0x210c =
|
||||
(characterLocation[3] >> 8 & 0xf0) + (characterLocation[2] >> 12);
|
||||
}
|
||||
}
|
||||
|
||||
void restoreCharacterLocation(byte bgNumber) {
|
||||
setCharacterLocation(characterLocation[bgNumber], bgNumber);
|
||||
void restoreCharacterLocation(byte bgNumber)
|
||||
{
|
||||
setCharacterLocation(characterLocation[bgNumber], bgNumber);
|
||||
}
|
||||
|
||||
void VRAMByteWrite(byte value, word vramDst) {
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = vramDst;
|
||||
void VRAMByteWrite(byte value, word vramDst)
|
||||
{
|
||||
*(byte *) 0x2115 = 0x80;
|
||||
*(word *) 0x2116 = vramDst;
|
||||
|
||||
*(byte*)0x2118 = value;
|
||||
*(byte *) 0x2118 = value;
|
||||
}
|
||||
|
||||
void VRAMLoad(word src, word vramDst, word size) {
|
||||
// set address in VRam for read or write ($2116) + block size transfer ($2115)
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = vramDst;
|
||||
void VRAMLoad(word src, word vramDst, word size)
|
||||
{
|
||||
// set address in VRam for read or write ($2116) + block size transfer ($2115)
|
||||
*(byte *) 0x2115 = 0x80;
|
||||
*(word *) 0x2116 = vramDst;
|
||||
|
||||
*(word*)0x4300 = 0x1801; // set DMA control register (1 word inc)
|
||||
// and destination ($21xx xx -> 0x18)
|
||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
*(word *) 0x4300 = 0x1801; // set DMA control register (1 word inc)
|
||||
// and destination ($21xx xx -> 0x18)
|
||||
*(word *) 0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte *) 0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word *) 0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte*)0x2100 = 0x80;
|
||||
*(byte*)0x420b = 0x01;
|
||||
*(byte*)0x2100 = 0x00;
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte *) 0x2100 = 0x80;
|
||||
*(byte *) 0x420b = 0x01;
|
||||
*(byte *) 0x2100 = 0x00;
|
||||
}
|
||||
|
||||
void CGRAMLoad(word src, byte cgramDst, word size) {
|
||||
void CGRAMLoad(word src, byte cgramDst, word size)
|
||||
{
|
||||
|
||||
// set address in VRam for read or write + block size
|
||||
*(byte*)0x2121 = cgramDst;
|
||||
// set address in VRam for read or write + block size
|
||||
*(byte *) 0x2121 = cgramDst;
|
||||
|
||||
*(word*)0x4300 = 0x2200; // set DMA control register (1 byte inc)
|
||||
// and destination ($21xx xx -> 022)
|
||||
*(word*)0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte*)0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word*)0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
*(word *) 0x4300 = 0x2200; // set DMA control register (1 byte inc)
|
||||
// and destination ($21xx xx -> 022)
|
||||
*(word *) 0x4302 = src; // DMA channel x source address offset
|
||||
// (low $4302 and high $4303 optimisation)
|
||||
*(byte *) 0x4304 = 0x01; // DMA channel x source address bank
|
||||
*(word *) 0x4305 = size; // DMA channel x transfer size
|
||||
// (low $4305 and high $4306 optimisation)
|
||||
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte*)0x2100 = 0x80;
|
||||
*(byte*)0x420b = 0x01;
|
||||
*(byte*)0x2100 = 0x00;
|
||||
// Turn on DMA transfer for this channel
|
||||
waitForVBlank();
|
||||
*(byte *) 0x2100 = 0x80;
|
||||
*(byte *) 0x420b = 0x01;
|
||||
*(byte *) 0x2100 = 0x00;
|
||||
}
|
||||
@ -1,37 +1,37 @@
|
||||
#include "data.h"
|
||||
|
||||
|
||||
word crc_update (char far *data, word size)
|
||||
word crc_update(char far * data, word size)
|
||||
{
|
||||
word i;
|
||||
word i;
|
||||
word j;
|
||||
word crc=0;
|
||||
for (j=0; j<size; j++){
|
||||
crc = crc ^ ((word)data[j]<< 8);
|
||||
for (i=0; i<8; i++){
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
word crc = 0;
|
||||
for (j = 0; j < size; j++) {
|
||||
crc = crc ^ ((word) data[j] << 8);
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
word crc_update_mem (unsigned long addr, word size)
|
||||
word crc_update_mem(unsigned long addr, word size)
|
||||
{
|
||||
word i;
|
||||
word i;
|
||||
word j;
|
||||
word crc=0;
|
||||
for (j=0; j<size; j++){
|
||||
crc = crc ^ ((word) *(byte*)(addr+j)<< 8);
|
||||
for (i=0; i<8; i++){
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
word crc = 0;
|
||||
for (j = 0; j < size; j++) {
|
||||
crc = crc ^ ((word) * (byte *) (addr + j) << 8);
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
else
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
@ -17,69 +17,74 @@ static char debug_buffer[512];
|
||||
static char screen_buffer[512];
|
||||
|
||||
|
||||
void debug_init(void) {
|
||||
word i;
|
||||
for(i=0; i<0x400; i++) {
|
||||
debugMap[i] = 0x00;
|
||||
}
|
||||
memset(debug_buffer,0,255);
|
||||
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);
|
||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
||||
setCharacterLocation(0x5000, (byte) 0);
|
||||
*(byte*) 0x2100 = 0x0f; // enable background
|
||||
void debug_enable(void)
|
||||
{
|
||||
VRAMLoad((word) debugFont_pic, 0x5000, 2048);
|
||||
VRAMLoad((word) debugMap, 0x4000, 0x0800);
|
||||
setTileMapLocation(0x4000, (byte) 0x00, (byte) 0);
|
||||
setCharacterLocation(0x5000, (byte) 0);
|
||||
*(byte *) 0x2100 = 0x0f; // enable background
|
||||
|
||||
// Font Color
|
||||
// hex(24 << 10 | 24 << 5 | 24 ) = '0x6318'
|
||||
*(byte*) 0x2121 = 0x02;
|
||||
*(byte*) 0x2122 = 0xff;
|
||||
*(byte*) 0x2122 = 0x7f;
|
||||
*(byte *) 0x2121 = 0x02;
|
||||
*(byte *) 0x2122 = 0xff;
|
||||
*(byte *) 0x2122 = 0x7f;
|
||||
|
||||
// Font Border Color
|
||||
*(byte*) 0x2121 = 0x00;
|
||||
*(byte*) 0x2122 = 0x00;
|
||||
*(byte*) 0x2122 = 0x00;
|
||||
*(byte *) 0x2121 = 0x00;
|
||||
*(byte *) 0x2122 = 0x00;
|
||||
*(byte *) 0x2122 = 0x00;
|
||||
|
||||
// Background Color
|
||||
*(byte*) 0x2121 = 0x01;
|
||||
*(byte*) 0x2122 = 0x05;
|
||||
*(byte*) 0x2122 = 0x29;
|
||||
*(byte *) 0x2121 = 0x01;
|
||||
*(byte *) 0x2122 = 0x05;
|
||||
*(byte *) 0x2122 = 0x29;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void clears(void) {
|
||||
word i,y;
|
||||
for(y=0; y<20; y++){
|
||||
waitForVBlank();
|
||||
for(i=0; i<32; i++){
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+i+(y*0x20);
|
||||
*(byte*)0x2118 = 0;
|
||||
}
|
||||
}
|
||||
void clears(void)
|
||||
{
|
||||
word i, y;
|
||||
for (y = 0; y < 20; y++) {
|
||||
waitForVBlank();
|
||||
for (i = 0; i < 32; i++) {
|
||||
*(byte *) 0x2115 = 0x80;
|
||||
*(word *) 0x2116 = 0x4000 + i + (y * 0x20);
|
||||
*(byte *) 0x2118 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _print_char(word y,word x, char c){
|
||||
waitForVBlank();
|
||||
VRAMByteWrite((byte) (c-32), (word) (0x4000+x+(y*0x20)));
|
||||
void _print_char(word y, word x, char c)
|
||||
{
|
||||
waitForVBlank();
|
||||
VRAMByteWrite((byte) (c - 32), (word) (0x4000 + x + (y * 0x20)));
|
||||
}
|
||||
|
||||
void _print_screen(word y, char *buffer){
|
||||
void _print_screen(word y, char *buffer)
|
||||
{
|
||||
char l;
|
||||
char x = 0;
|
||||
l = strlen(buffer);
|
||||
waitForVBlank();
|
||||
while(*buffer){
|
||||
if (*buffer == '\n' ) {
|
||||
while(x++<32){
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||
*(byte*)0x2118 = 0;
|
||||
while (*buffer) {
|
||||
if (*buffer == '\n') {
|
||||
while (x++ < 32) {
|
||||
*(byte *) 0x2115 = 0x80;
|
||||
*(word *) 0x2116 = 0x4000 + x + (y * 0x20);
|
||||
*(byte *) 0x2118 = 0;
|
||||
}
|
||||
x = 0;
|
||||
y++;
|
||||
@ -87,9 +92,9 @@ void _print_screen(word y, char *buffer){
|
||||
waitForVBlank();
|
||||
continue;
|
||||
}
|
||||
*(byte*)0x2115 = 0x80;
|
||||
*(word*)0x2116 = 0x4000+x+(y*0x20);
|
||||
*(byte*)0x2118 = *buffer-32;
|
||||
*(byte *) 0x2115 = 0x80;
|
||||
*(word *) 0x2116 = 0x4000 + x + (y * 0x20);
|
||||
*(byte *) 0x2118 = *buffer - 32;
|
||||
x++;
|
||||
buffer++;
|
||||
#if 0
|
||||
@ -97,101 +102,113 @@ void _print_screen(word y, char *buffer){
|
||||
#endif
|
||||
}
|
||||
}
|
||||
void _print_console(const char *buffer){
|
||||
while(*buffer)
|
||||
*(byte*) 0x3000=*buffer++;
|
||||
void _print_console(const char *buffer)
|
||||
{
|
||||
while (*buffer)
|
||||
*(byte *) 0x3000 = *buffer++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void printfc(const char *fmt,...){
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vsprintf(debug_buffer,fmt,ap);
|
||||
va_end(ap);
|
||||
_print_console(debug_buffer);
|
||||
//memset(debug_buffer,0,255);
|
||||
void printfc(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsprintf(debug_buffer, fmt, ap);
|
||||
va_end(ap);
|
||||
_print_console(debug_buffer);
|
||||
// memset(debug_buffer,0,255);
|
||||
|
||||
}
|
||||
|
||||
void printfs(word y,const char *fmt,...){
|
||||
va_list ap;
|
||||
va_start(ap,fmt);
|
||||
vsprintf(screen_buffer,fmt,ap);
|
||||
va_end(ap);
|
||||
_print_screen(y,screen_buffer);
|
||||
memset(screen_buffer,0,255);
|
||||
void printfs(word y, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsprintf(screen_buffer, fmt, ap);
|
||||
va_end(ap);
|
||||
_print_screen(y, screen_buffer);
|
||||
memset(screen_buffer, 0, 255);
|
||||
}
|
||||
|
||||
void printc_packet(unsigned long addr,unsigned int len,byte *packet){
|
||||
unsigned int i,j;
|
||||
unsigned int sum = 0;
|
||||
unsigned int clear=0;
|
||||
void printc_packet(unsigned long addr, unsigned int len, byte * packet)
|
||||
{
|
||||
unsigned int i, j;
|
||||
unsigned int sum = 0;
|
||||
unsigned int clear = 0;
|
||||
|
||||
for (i=0;i<len;i+=16) {
|
||||
for (i = 0; i < len; i += 16) {
|
||||
|
||||
sum = 0;
|
||||
for (j=0;j<16;j++) {
|
||||
sum +=packet[i+j];
|
||||
}
|
||||
if (!sum){
|
||||
clear=1;
|
||||
continue;
|
||||
}
|
||||
if (clear){
|
||||
printfc("*\n");
|
||||
clear = 0;
|
||||
}
|
||||
printfc("%lx:", addr + i);
|
||||
for (j=0;j<16;j++) {
|
||||
printfc(" %x", packet[i+j]);
|
||||
}
|
||||
printfc(" |");
|
||||
for (j=0;j<16;j++) {
|
||||
if (packet[i+j]>=33 && packet[i+j]<=126 )
|
||||
printfc("%c", packet[i+j]);
|
||||
else
|
||||
printfc(".");
|
||||
}
|
||||
printfc("|\n");
|
||||
}
|
||||
sum = 0;
|
||||
for (j = 0; j < 16; j++) {
|
||||
sum += packet[i + j];
|
||||
}
|
||||
if (!sum) {
|
||||
clear = 1;
|
||||
continue;
|
||||
}
|
||||
if (clear) {
|
||||
printfc("*\n");
|
||||
clear = 0;
|
||||
}
|
||||
printfc("%lx:", addr + i);
|
||||
for (j = 0; j < 16; j++) {
|
||||
printfc(" %x", packet[i + j]);
|
||||
}
|
||||
printfc(" |");
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (packet[i + j] >= 33 && packet[i + j] <= 126)
|
||||
printfc("%c", packet[i + j]);
|
||||
else
|
||||
printfc(".");
|
||||
}
|
||||
printfc("|\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* keep the linker happy */
|
||||
int open(const char * _name, int _mode){
|
||||
/*
|
||||
* keep the linker happy
|
||||
*/
|
||||
int open(const char *_name, int _mode)
|
||||
{
|
||||
_print_console("open called\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int close(int fd){
|
||||
int close(int fd)
|
||||
{
|
||||
_print_console("close called\n");
|
||||
return -1;
|
||||
|
||||
}
|
||||
|
||||
size_t read(int fd, void * buff, size_t len){
|
||||
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){
|
||||
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){
|
||||
long lseek(int fd, long off, int count)
|
||||
{
|
||||
_print_console("lseek called\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unlink(const char * name){
|
||||
int unlink(const char *name)
|
||||
{
|
||||
_print_console("unlink called\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int isatty(){
|
||||
int isatty()
|
||||
{
|
||||
_print_console("isatty called\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -7,25 +7,18 @@
|
||||
|
||||
|
||||
|
||||
/* Interface
|
||||
** Scratch Buffer
|
||||
addr 3 byte
|
||||
size 1 byte
|
||||
|
||||
** Call Interface
|
||||
cmd 1 byte
|
||||
sector 4 bytes
|
||||
count 1 byte
|
||||
return 1 byte
|
||||
|
||||
** Commands
|
||||
* disk_init
|
||||
* disk_read
|
||||
* disk_write
|
||||
*/
|
||||
/*
|
||||
* Interface ** Scratch Buffer addr 3 byte size 1 byte
|
||||
*
|
||||
* ** Call Interface cmd 1 byte sector 4 bytes count 1 byte return 1 byte
|
||||
*
|
||||
* ** Commands * disk_init * disk_read * disk_write
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Initialize Disk Drive */
|
||||
/*
|
||||
* Initialize Disk Drive
|
||||
*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
@ -33,158 +26,175 @@ return 1 byte
|
||||
|
||||
// TODO: Figure out gobal vars ?!?
|
||||
|
||||
DSTATUS Stat = 0 ; //STA_NOINIT; /* Disk status */
|
||||
DSTATUS Stat = 0; // STA_NOINIT; /* Disk status */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE drv) {
|
||||
DSTATUS disk_initialize(BYTE drv)
|
||||
{
|
||||
|
||||
byte retval;
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: called drv=%i stat=%i\n",drv,Stat);
|
||||
#endif
|
||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: called drv=%i stat=%i\n", drv, Stat);
|
||||
#endif
|
||||
if (drv)
|
||||
return STA_NOINIT; /* Supports only single drive */
|
||||
Stat |= STA_NOINIT;
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: stat=%i\n",Stat);
|
||||
#endif
|
||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||
*(byte*) MMIO_CMD = CMD_INIT;
|
||||
#ifdef MMIO_DEBUG
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: stat=%i\n", Stat);
|
||||
#endif
|
||||
*(byte *) MMIO_RETVAL = STA_VOID;
|
||||
*(byte *) MMIO_CMD = CMD_INIT;
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: poll retval\n");
|
||||
#endif
|
||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: done Stat=%i\n",Stat);
|
||||
#endif
|
||||
#endif
|
||||
while ((retval = *(byte *) MMIO_RETVAL) == STA_VOID);
|
||||
Stat &= ~STA_NOINIT; /* When device goes ready, clear STA_NOINIT */
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_initialize: done Stat=%i\n", Stat);
|
||||
#endif
|
||||
return Stat;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Return Disk Status */
|
||||
/*
|
||||
* Return Disk Status
|
||||
*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DSTATUS disk_status (BYTE drv){
|
||||
if (drv) return STA_NOINIT; /* Supports only single drive */
|
||||
DSTATUS disk_status(BYTE drv)
|
||||
{
|
||||
if (drv)
|
||||
return STA_NOINIT; /* Supports only single drive */
|
||||
return Stat;
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Read Sector(s) */
|
||||
/*
|
||||
* Read Sector(s)
|
||||
*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
DRESULT disk_read (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE *buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
)
|
||||
DRESULT disk_read(BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE * buff, /* Data buffer to store read data */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
DWORD offset;
|
||||
INT size;
|
||||
byte retval;
|
||||
word i;
|
||||
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: sector=%li count=%i\n",sector,count);
|
||||
#endif
|
||||
if (drv || !count) return RES_PARERR;
|
||||
#ifdef MMIO_DEBUG
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: sector=%li count=%i\n", sector, count);
|
||||
#endif
|
||||
if (drv || !count)
|
||||
return RES_PARERR;
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: drv ok\n");
|
||||
#endif
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
#ifdef MMIO_DEBUG
|
||||
#endif
|
||||
if (Stat & STA_NOINIT)
|
||||
return RES_NOTRDY;
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: sta ok\n");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
*(byte*) MMIO_RETVAL = STA_VOID;
|
||||
*(byte*) MMIO_CMD = CMD_READ;
|
||||
*(byte *) MMIO_RETVAL = STA_VOID;
|
||||
*(byte *) MMIO_CMD = CMD_READ;
|
||||
|
||||
*(byte*) MMIO_SECTOR01 = (sector >> 24) & 0xff;
|
||||
*(byte*) MMIO_SECTOR02 = (sector >> 16) & 0xff;
|
||||
*(byte*) MMIO_SECTOR03 = (sector >> 8) & 0xff;
|
||||
*(byte*) MMIO_SECTOR04 = (sector) & 0xff;
|
||||
*(byte *) MMIO_SECTOR01 = (sector >> 24) & 0xff;
|
||||
*(byte *) MMIO_SECTOR02 = (sector >> 16) & 0xff;
|
||||
*(byte *) MMIO_SECTOR03 = (sector >> 8) & 0xff;
|
||||
*(byte *) MMIO_SECTOR04 = (sector) & 0xff;
|
||||
|
||||
*(byte*) MMIO_COUNT = count;
|
||||
*(byte *) MMIO_COUNT = count;
|
||||
|
||||
#ifdef MMIO_DEBUG
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: poll retval\n");
|
||||
#endif
|
||||
while((retval = *(byte*) MMIO_RETVAL) == STA_VOID);
|
||||
#endif
|
||||
while ((retval = *(byte *) MMIO_RETVAL) == STA_VOID);
|
||||
|
||||
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: copy buffer to %lx\n",SHARED_ADDR);
|
||||
#endif
|
||||
for (i=0;i<(count*512);i++){
|
||||
buff[i] = *(byte*)(SHARED_ADDR+i);
|
||||
#ifdef MMIO_DEBUG
|
||||
if ( i < 4)
|
||||
printfc("0x%x ",buff[i]);
|
||||
#endif
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("SNES::disk_read: copy buffer to %lx\n", SHARED_ADDR);
|
||||
#endif
|
||||
for (i = 0; i < (count * 512); i++) {
|
||||
buff[i] = *(byte *) (SHARED_ADDR + i);
|
||||
#ifdef MMIO_DEBUG
|
||||
if (i < 4)
|
||||
printfc("0x%x ", buff[i]);
|
||||
#endif
|
||||
}
|
||||
#ifdef MMIO_DEBUG
|
||||
#ifdef MMIO_DEBUG
|
||||
printfc("\n");
|
||||
#endif
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Write Sector(s) */
|
||||
/*
|
||||
* Write Sector(s)
|
||||
*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _READONLY == 0
|
||||
DRESULT disk_write (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
const BYTE *buff, /* Data to be written */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
)
|
||||
DRESULT disk_write(BYTE drv, /* Physical drive nmuber (0) */
|
||||
const BYTE * buff, /* Data to be written */
|
||||
DWORD sector, /* Sector number (LBA) */
|
||||
BYTE count /* Sector count (1..255) */
|
||||
)
|
||||
{
|
||||
DWORD offset;
|
||||
INT size;
|
||||
|
||||
if (drv || !count) return RES_PARERR;
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
if (drv || !count)
|
||||
return RES_PARERR;
|
||||
if (Stat & STA_NOINIT)
|
||||
return RES_NOTRDY;
|
||||
|
||||
offset = sector * 512;
|
||||
offset = sector * 512;
|
||||
size = count * 512;
|
||||
return RES_OK;
|
||||
}
|
||||
#endif /* _READONLY */
|
||||
#endif /* _READONLY */
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Miscellaneous Functions */
|
||||
/*
|
||||
* Miscellaneous Functions
|
||||
*/
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
#if _USE_IOCTL != 0
|
||||
DRESULT disk_ioctl (
|
||||
BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE ctrl, /* Control code */
|
||||
void *buff /* Buffer to send/receive data block */
|
||||
)
|
||||
DRESULT disk_ioctl(BYTE drv, /* Physical drive nmuber (0) */
|
||||
BYTE ctrl, /* Control code */
|
||||
void *buff /* Buffer to send/receive data block */
|
||||
)
|
||||
{
|
||||
BYTE n, w, ofs, dl, dh, *ptr = (BYTE*)buff;
|
||||
BYTE n, w, ofs, dl, dh, *ptr = (BYTE *) buff;
|
||||
|
||||
|
||||
if (drv) return RES_PARERR;
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
if (drv)
|
||||
return RES_PARERR;
|
||||
if (Stat & STA_NOINIT)
|
||||
return RES_NOTRDY;
|
||||
|
||||
switch (ctrl) {
|
||||
case GET_SECTOR_COUNT : /* Get number of sectors on the disk (DWORD) */
|
||||
ofs = 60; w = 2; n = 0;
|
||||
case GET_SECTOR_COUNT: /* Get number of sectors on the disk (DWORD) */
|
||||
ofs = 60;
|
||||
w = 2;
|
||||
n = 0;
|
||||
break;
|
||||
|
||||
case GET_SECTOR_SIZE : /* Get sectors on the disk (WORD) */
|
||||
*(WORD*)buff = 512;
|
||||
case GET_SECTOR_SIZE: /* Get sectors on the disk (WORD) */
|
||||
*(WORD *) buff = 512;
|
||||
return RES_OK;
|
||||
|
||||
case GET_BLOCK_SIZE : /* Get erase block size in sectors (DWORD) */
|
||||
*(DWORD*)buff = 32;
|
||||
case GET_BLOCK_SIZE: /* Get erase block size in sectors (DWORD) */
|
||||
*(DWORD *) buff = 32;
|
||||
return RES_OK;
|
||||
|
||||
default:
|
||||
@ -192,8 +202,4 @@ DRESULT disk_ioctl (
|
||||
}
|
||||
return RES_OK;
|
||||
}
|
||||
#endif /* _USE_IOCTL != 0 */
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* _USE_IOCTL != 0 */
|
||||
|
||||
@ -5,97 +5,102 @@
|
||||
|
||||
event *events;
|
||||
|
||||
void initEvents(void) {
|
||||
events = NULL;
|
||||
void initEvents(void)
|
||||
{
|
||||
events = NULL;
|
||||
}
|
||||
|
||||
event *createEvent(char (*callback)(word counter)) {
|
||||
event *myEvent;
|
||||
event *createEvent(char (*callback) (word counter))
|
||||
{
|
||||
event *myEvent;
|
||||
|
||||
myEvent = (event*) malloc(sizeof(event));
|
||||
myEvent = (event *) malloc(sizeof(event));
|
||||
|
||||
myEvent->VBlankCount = 0;
|
||||
myEvent->callback = callback;
|
||||
myEvent->nextEvent = NULL;
|
||||
myEvent->previousEvent = NULL;
|
||||
myEvent->VBlankCount = 0;
|
||||
myEvent->callback = callback;
|
||||
myEvent->nextEvent = NULL;
|
||||
myEvent->previousEvent = NULL;
|
||||
|
||||
|
||||
return myEvent;
|
||||
return myEvent;
|
||||
}
|
||||
|
||||
event* addEvent(char (*callback)(word counter), int noDuplicateCallback) {
|
||||
event *addEvent(char (*callback) (word counter), int noDuplicateCallback)
|
||||
{
|
||||
|
||||
event *lastEvent;
|
||||
event *myEvent;
|
||||
event *lastEvent;
|
||||
event *myEvent;
|
||||
|
||||
if(events == NULL) {
|
||||
events = createEvent(callback);
|
||||
return events;
|
||||
} else {
|
||||
lastEvent = events;
|
||||
// TODO optimise this with noduplicate
|
||||
while(lastEvent->nextEvent != NULL) {
|
||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
lastEvent = lastEvent->nextEvent;
|
||||
}
|
||||
if(noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
myEvent = createEvent(callback);
|
||||
myEvent->previousEvent = lastEvent;
|
||||
lastEvent->nextEvent = myEvent;
|
||||
return myEvent;
|
||||
}
|
||||
if (events == NULL) {
|
||||
events = createEvent(callback);
|
||||
return events;
|
||||
} else {
|
||||
lastEvent = events;
|
||||
// TODO optimise this with noduplicate
|
||||
while (lastEvent->nextEvent != NULL) {
|
||||
if (noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
lastEvent = lastEvent->nextEvent;
|
||||
}
|
||||
if (noDuplicateCallback == 1 && lastEvent->callback == *callback) {
|
||||
return NULL;
|
||||
}
|
||||
myEvent = createEvent(callback);
|
||||
myEvent->previousEvent = lastEvent;
|
||||
lastEvent->nextEvent = myEvent;
|
||||
return myEvent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void removeEvent(event *eventElement) {
|
||||
void removeEvent(event * eventElement)
|
||||
{
|
||||
|
||||
byte alone = 0;
|
||||
event *next, *previous;
|
||||
byte alone = 0;
|
||||
event *next, *previous;
|
||||
|
||||
next = eventElement->nextEvent;
|
||||
previous = eventElement->previousEvent;
|
||||
next = eventElement->nextEvent;
|
||||
previous = eventElement->previousEvent;
|
||||
|
||||
if(eventElement->nextEvent != NULL && eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = previous;
|
||||
previous->nextEvent = next;
|
||||
if (eventElement->nextEvent != NULL && eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = previous;
|
||||
previous->nextEvent = next;
|
||||
|
||||
} else if(eventElement->nextEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = NULL;
|
||||
events = next;
|
||||
} else if (eventElement->nextEvent != NULL) {
|
||||
alone++;
|
||||
next->previousEvent = NULL;
|
||||
events = next;
|
||||
|
||||
} else if(eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
previous->nextEvent = NULL;
|
||||
}
|
||||
} else if (eventElement->previousEvent != NULL) {
|
||||
alone++;
|
||||
previous->nextEvent = NULL;
|
||||
}
|
||||
|
||||
free(eventElement);
|
||||
free(eventElement);
|
||||
|
||||
if(alone == 0) {
|
||||
events = NULL;
|
||||
}
|
||||
if (alone == 0) {
|
||||
events = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void processEvents(void) {
|
||||
void processEvents(void)
|
||||
{
|
||||
|
||||
event *currentEvent;
|
||||
char returnValue;
|
||||
event *currentEvent;
|
||||
char returnValue;
|
||||
|
||||
currentEvent = events;
|
||||
while(currentEvent != NULL) {
|
||||
returnValue = currentEvent->callback(currentEvent->VBlankCount);
|
||||
if(returnValue == EVENT_CONTINUE) {
|
||||
currentEvent->VBlankCount++;
|
||||
} else {
|
||||
removeEvent(currentEvent);
|
||||
}
|
||||
currentEvent = currentEvent->nextEvent;
|
||||
}
|
||||
currentEvent = events;
|
||||
while (currentEvent != NULL) {
|
||||
returnValue = currentEvent->callback(currentEvent->VBlankCount);
|
||||
if (returnValue == EVENT_CONTINUE) {
|
||||
currentEvent->VBlankCount++;
|
||||
} else {
|
||||
removeEvent(currentEvent);
|
||||
}
|
||||
currentEvent = currentEvent->nextEvent;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
4502
snes/fatfstest/ff.c
4502
snes/fatfstest/ff.c
File diff suppressed because it is too large
Load Diff
@ -13,18 +13,6 @@
|
||||
#include "debug.h"
|
||||
#include "crc.h"
|
||||
|
||||
/*
|
||||
|
||||
o relocate main code
|
||||
o exec loaded file
|
||||
|
||||
o debug STA global
|
||||
o optimize internal transfer buffer
|
||||
o direct writeto mempage
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#define ROM_NAME "TURRICAN.SMC"
|
||||
#define BLOCK_SIZE 512
|
||||
@ -32,14 +20,14 @@ o direct writeto mempage
|
||||
#define BANK_COUNT 16
|
||||
#define BASE_ADDR 0x008000
|
||||
|
||||
typedef void (*FUNC)(void);
|
||||
typedef void (*FUNC) (void);
|
||||
|
||||
padStatus pad1;
|
||||
DWORD acc_size; /* Work register for fs command */
|
||||
WORD acc_files, acc_dirs;
|
||||
FILINFO finfo;
|
||||
FATFS fatfs[2]; /* File system object for each logical * drive */
|
||||
//BYTE Buff[512]; /* Working buffer */
|
||||
// BYTE Buff[512]; /* Working buffer */
|
||||
DWORD p1, p2, p3;
|
||||
DWORD addr;
|
||||
DWORD crc_addr;
|
||||
@ -57,7 +45,9 @@ void initInternalRegisters(void)
|
||||
characterLocation[2] = 0x0000;
|
||||
characterLocation[3] = 0x0000;
|
||||
debug_init();
|
||||
} void preInit(void)
|
||||
}
|
||||
|
||||
void preInit(void)
|
||||
{
|
||||
|
||||
// For testing purpose ...
|
||||
@ -137,7 +127,7 @@ void wait(void)
|
||||
void boot(DWORD addr)
|
||||
{
|
||||
FUNC fn;
|
||||
printfc("SNES::boot addr=%lx\n",addr);
|
||||
printfc("SNES::boot addr=%lx\n", addr);
|
||||
fn = (FUNC) addr;
|
||||
fn();
|
||||
|
||||
@ -153,7 +143,7 @@ void boot(DWORD addr)
|
||||
|
||||
debug_enable();
|
||||
printfc("SNES::main: Try to init disk\n");
|
||||
put_rc(f_mount((BYTE)0, &fatfs[0]));
|
||||
put_rc(f_mount((BYTE) 0, &fatfs[0]));
|
||||
|
||||
printfs(0, "FATFS OPTIXX.ORG ");
|
||||
printfc("SNES::main: Try to get free\n");
|
||||
@ -228,7 +218,7 @@ void boot(DWORD addr)
|
||||
|
||||
printfc("SNES::main: open %s \n", ROM_NAME);
|
||||
printfs(0, "OPEN %s", ROM_NAME);
|
||||
put_rc(f_open(&file1, ROM_NAME, (BYTE)FA_READ));
|
||||
put_rc(f_open(&file1, ROM_NAME, (BYTE) FA_READ));
|
||||
p1 = BANK_SIZE * BANK_COUNT;
|
||||
p2 = 0;
|
||||
p3 = 0;
|
||||
@ -242,7 +232,7 @@ void boot(DWORD addr)
|
||||
res = f_read(&file1, (byte *) (addr), cnt, &s2);
|
||||
|
||||
|
||||
if (res != FR_OK) {
|
||||
if (res != FR_OK) {
|
||||
printfc("SNES::main: read failed\n");
|
||||
put_rc(res);
|
||||
break;
|
||||
@ -252,7 +242,6 @@ void boot(DWORD addr)
|
||||
printfc("SNES::main: read cnt=%i s2=%i\n", cnt, s2);
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printc_packet(addr, 512, (byte *) (addr));
|
||||
wait();
|
||||
@ -262,11 +251,11 @@ void boot(DWORD addr)
|
||||
|
||||
if (addr % 0x10000 == 0) {
|
||||
printfc("SNES::main: read cnt=%i p1=%li p2=%li s2=%i \n", cnt,
|
||||
p1, p2, s2);
|
||||
p1, p2, s2);
|
||||
#if 0
|
||||
crc = crc_update_mem(crc_addr,0x8000);
|
||||
printfc("SNES::main: crc_addr=%lx crc=%x\n",crc_addr,crc);
|
||||
crc_addr+=0x8000;
|
||||
crc = crc_update_mem(crc_addr, 0x8000);
|
||||
printfc("SNES::main: crc_addr=%lx crc=%x\n", crc_addr, crc);
|
||||
crc_addr += 0x8000;
|
||||
#endif
|
||||
printfs((1 + bank), "BANK %i ADDR 0X%lx ", bank, addr);
|
||||
|
||||
@ -275,9 +264,9 @@ void boot(DWORD addr)
|
||||
}
|
||||
}
|
||||
put_rc(f_close(&file1));
|
||||
addr = *(byte *)0xFFFD;
|
||||
addr = *(byte *) 0xFFFD;
|
||||
addr = addr << 8;
|
||||
addr |= (*(byte *)0xFFFC);
|
||||
addr |= (*(byte *) 0xFFFC);
|
||||
boot(addr);
|
||||
while (1) {
|
||||
wait();
|
||||
@ -287,7 +276,9 @@ void boot(DWORD addr)
|
||||
|
||||
void IRQHandler(void)
|
||||
{
|
||||
} void NMIHandler(void)
|
||||
}
|
||||
|
||||
void NMIHandler(void)
|
||||
{
|
||||
|
||||
// processEvents();
|
||||
|
||||
@ -5,93 +5,99 @@
|
||||
extern padStatus pad1;
|
||||
extern word scrollValue;
|
||||
|
||||
char fadeOut(word counter) {
|
||||
static byte fadeOutValue;
|
||||
char fadeOut(word counter)
|
||||
{
|
||||
static byte fadeOutValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
fadeOutValue = 0x0f;
|
||||
} else {
|
||||
fadeOutValue--;
|
||||
}
|
||||
if (counter == 0) {
|
||||
// init fade value
|
||||
fadeOutValue = 0x0f;
|
||||
} else {
|
||||
fadeOutValue--;
|
||||
}
|
||||
|
||||
*(byte*) 0x2100 = fadeOutValue;
|
||||
*(byte *) 0x2100 = fadeOutValue;
|
||||
|
||||
if(fadeOutValue == 0x00) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
if (fadeOutValue == 0x00) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char fadeIn(word counter) {
|
||||
static byte fadeInValue;
|
||||
char fadeIn(word counter)
|
||||
{
|
||||
static byte fadeInValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
fadeInValue = 0x00;
|
||||
} else {
|
||||
fadeInValue++;
|
||||
}
|
||||
if (counter == 0) {
|
||||
// init fade value
|
||||
fadeInValue = 0x00;
|
||||
} else {
|
||||
fadeInValue++;
|
||||
}
|
||||
|
||||
*(byte*) 0x2100 = fadeInValue;
|
||||
*(byte *) 0x2100 = fadeInValue;
|
||||
|
||||
if(fadeInValue >= 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
if (fadeInValue >= 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char mosaicOut(word counter) {
|
||||
static byte mosaicOutValue;
|
||||
char mosaicOut(word counter)
|
||||
{
|
||||
static byte mosaicOutValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
mosaicOutValue = 0xff;
|
||||
} else {
|
||||
mosaicOutValue -= 0x10;
|
||||
}
|
||||
if (counter == 0) {
|
||||
// init fade value
|
||||
mosaicOutValue = 0xff;
|
||||
} else {
|
||||
mosaicOutValue -= 0x10;
|
||||
}
|
||||
|
||||
*(byte*) 0x2106 = mosaicOutValue;
|
||||
*(byte *) 0x2106 = mosaicOutValue;
|
||||
|
||||
if(mosaicOutValue == 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
if (mosaicOutValue == 0x0f) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char mosaicIn(word counter) {
|
||||
static byte mosaicInValue;
|
||||
char mosaicIn(word counter)
|
||||
{
|
||||
static byte mosaicInValue;
|
||||
|
||||
if(counter == 0) {
|
||||
// init fade value
|
||||
mosaicInValue = 0x0f;
|
||||
} else {
|
||||
mosaicInValue += 0x10;
|
||||
}
|
||||
if (counter == 0) {
|
||||
// init fade value
|
||||
mosaicInValue = 0x0f;
|
||||
} else {
|
||||
mosaicInValue += 0x10;
|
||||
}
|
||||
|
||||
*(byte*) 0x2106 = mosaicInValue;
|
||||
*(byte *) 0x2106 = mosaicInValue;
|
||||
|
||||
if(mosaicInValue == 0xff) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
if (mosaicInValue == 0xff) {
|
||||
return EVENT_STOP;
|
||||
} else {
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
char NMIReadPad(word counter) {
|
||||
pad1 = readPad((byte) 0);
|
||||
char NMIReadPad(word counter)
|
||||
{
|
||||
pad1 = readPad((byte) 0);
|
||||
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
|
||||
char scrollLeft(word counter) {
|
||||
scrollValue++;
|
||||
char scrollLeft(word counter)
|
||||
{
|
||||
scrollValue++;
|
||||
|
||||
*(byte*) 0x210d = (byte) scrollValue;
|
||||
*(byte*) 0x210d = (byte) (scrollValue>>8);
|
||||
*(byte *) 0x210d = (byte) scrollValue;
|
||||
*(byte *) 0x210d = (byte) (scrollValue >> 8);
|
||||
|
||||
return EVENT_CONTINUE;
|
||||
return EVENT_CONTINUE;
|
||||
}
|
||||
@ -2,22 +2,25 @@
|
||||
#include "pad.h";
|
||||
#include "debug.h";
|
||||
|
||||
void enablePad(void) {
|
||||
// Enable pad reading and NMI
|
||||
*(byte*)0x4200 = 0x01;
|
||||
}
|
||||
|
||||
void disablePad(void) {
|
||||
void enablePad(void)
|
||||
{
|
||||
// Enable pad reading and NMI
|
||||
*(byte*)0x4200 = 0x00;
|
||||
*(byte *) 0x4200 = 0x01;
|
||||
}
|
||||
|
||||
padStatus readPad(byte padNumber) {
|
||||
word test;
|
||||
padStatus *status;
|
||||
padNumber = padNumber << 1;
|
||||
test = (word) *(byte*)0x4218+padNumber << 8;
|
||||
test |= (word) *(byte*)0x4219+padNumber;
|
||||
status = (padStatus *) &test;
|
||||
return *status;
|
||||
void disablePad(void)
|
||||
{
|
||||
// Enable pad reading and NMI
|
||||
*(byte *) 0x4200 = 0x00;
|
||||
}
|
||||
|
||||
padStatus readPad(byte padNumber)
|
||||
{
|
||||
word test;
|
||||
padStatus *status;
|
||||
padNumber = padNumber << 1;
|
||||
test = (word) * (byte *) 0x4218 + padNumber << 8;
|
||||
test |= (word) * (byte *) 0x4219 + padNumber;
|
||||
status = (padStatus *) & test;
|
||||
return *status;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user