PDA

View Full Version : Controller/keyboard input without KOS



fox68k
August 3rd, 2004, 10:39
Hi,

i need basic input (controller or keyboard, keyboard preferred) in my program, but since it is big to upload it through serial cable (i don't own a BBA :-/) i don't want to use KOS.

I've been looking at Marcus notes, but i can't figure it out.

Anyone knows an easy way to get access to the state of the controller/keyboard without KOS?

Thanks in advance.

quzar
August 3rd, 2004, 10:50
kos isnt that big... it will only take a bit more to link in with kos and save lots of time from writing your own functions.

Also, I would reccomend visiting www.DCEmulation.com and the forums there. There is a much larger user base there and most of the current DC coders visit there more regularly than here.

fox68k
August 3rd, 2004, 10:59
My program is currently big. It is because the jump table in the emu core.
I don't want to get it bigger since i am testing the core and i need to upload it so many times while i fix errors, etc.
I only need a function to control the execution flow, nothing complex.

I will ask for this in dcemulation.com too.

Darksaviour69
August 3rd, 2004, 15:03
Dan and a few other coders vist consolevision.com

CSV is the only DC scene site dan goes to

BlackAura
August 3rd, 2004, 19:47
You could try libdream, or libronin. libdream is the predecessor of KOS, and it a lot smaller. It's also a lot less functional and difficult to use, but if you just want something you can use to debug the emulator core, it should be fine. libronin is like libdream, but it was originally part of DreamSNES.

Kamjin
August 3rd, 2004, 21:45
Deja Vu???? posted this at the other spot already...
but I like this place so..

here you go.. Kosfree.. if you're using Marcus's Maple stuff,
just make sure you re-organise the parameters, mine is sent
as it is seen on the maple, this should be enough to get the keyboard
going as well.. same location as digital, except 1byte=shift/alt status
next byte is the LEDs, and then 6chars of 6 keys being pressed..
a note of caution, if you start getting back 0xFFFF's then toss the
data and poll it again.. it does that sometimes...


#include <math.h>

unsigned char dmabuffer[2128];

void *maple_docmd(int port, int unit, int cmd, int len, void *data)
{
*unsigned long *sbuf, *rbuf;
*int dst, src;
*src = port << 6;
*if(unit==0){
* * * *dst=0x0020;
*}else{
* * * *dst=((1<<(unit-1))&0x1f);
*}
*dst=((port<<6)+dst);

*rbuf = (unsigned long *) ((((unsigned long)dmabuffer+0x20)& 0xffffffe0)|0xa0000000);
*sbuf = (unsigned long *) (((unsigned char *)rbuf) + 1024);
* while((*(volatile unsigned long *)(0xa05f6c18)) & 1);//DMA Busy?
**(volatile unsigned long *)(0xa05f6c04) = ((unsigned long)sbuf) & 0xfffffff;
**sbuf++ = len + (port * 0x10000) + 0x80000000;
**sbuf++ = ((unsigned long)rbuf) & 0xfffffff;
**sbuf++ = (cmd & 0xff) + (dst * 0x100) + (src *0x10000) + (len * 0x1000000);
* if(len > 0) {
* * * * *unsigned long *param = data;
* * * * *int i;
* * * * *for(i=0; i<len; i++)*sbuf++ = *param++;
*}
**(volatile unsigned long *)(0xa05f6c18) = 1;//do dma..
* while((*(volatile unsigned long *)(0xa05f6c18)) & 1);
* return rbuf;
}//end



void delay(int t){
* * *float x = 1;
* * *while(t-->0)x=cos(x);
}//end delay


void main(void)
{
*unsigned int i=0,params[2];
*unsigned short *res,digital,trigger,joystick;

*//maple init
**(volatile unsigned long *)(0xa05f6c8c)= 0x6155404f;
**(volatile unsigned long *)(0xa05f6c10) = 0;
**(volatile unsigned long *)(0xa05f6c80) = 0xc3500000;
**(volatile unsigned long *)(0xa05f6c14) = 1;

while(i==0){
* * * * *params[0]=0x01000000; //controller
* * * * *do res = maple_docmd(0, 0, 9, 1, params);
* * * * *while(*res == -4);
* * * * *res+=4;//Dpad and buttons
* * * * *digital=*res; //for explination purposes..
* * * * **res++; * * * //but just make this a simple struct
* * * * *trigger=*res;
* * * * **res++;
* * * * *joystick=*res;//didn't bother.. but same as triggers
* * * * *
* * * * *printf("RT:%d\n",(trigger&0x00ff));
* * * * *printf("LT:%d\n\n",(trigger/=0x100));

* * * * *if(!(digital&0x0010))printf("Up\n");
* * * * *if(!(digital&0x0020))printf("Down\n");
* * * * *if(!(digital&0x0080))printf("Right\n");
* * * * *if(!(digital&0x0040))printf("Left\n");
* * * * *if(!(digital&0x0200))printf("Y\n");
* * * * *if(!(digital&0x0004))printf("A\n");
* * * * *if(!(digital&0x0002))printf("B\n");
* * * * *if(!(digital&0x0400))printf("X\n");
* * * * *if(!(digital&0x0008)){
* * * * * * * * * * * * printf("START\n");
* * * * * * * * * * * *i=1;//and exit
* * * * *}
* * * * *delay(500000);
}//end while