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
Powered by vBulletin® Version 4.2.3 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.