gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > GBA - programming external devices (parallel port)

#44750 - ghost Leinad - Sun Jun 05, 2005 1:31 am

please...i need this by tomorrow!!!!

there's any way to use an external pad in the Visual boy advance...device is connected in the parallel port (base address 378h)...but without using any drivers...

pseudocode

_asm
{
mov dx,378h //base address
in dx,al // signal
}

if(AL,1)
{
c='1' // if c=1 my button one is activated
}

i know that i can do that in plain c but when programming on GBA???

please how this could be done...and i need this information by tomorrow
meanwhile i'll do some investigation by my own

thank you very much

#44777 - tepples - Sun Jun 05, 2005 5:48 am

I can't exactly understand what you're asking for. Do you want to get the GBA to read its main 10-button controller, or do you want to get the GBA to read an external Super NES controller connected to the link port?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44779 - cory1492 - Sun Jun 05, 2005 6:38 am

I think what he is attempting to do is code for a Visual Boy Advanced controller 'plugin' from within the gba code instead of just using VBA+regular controller drivers+Joypad options, I doubt you are able to directly access the PC hardware (ie: lpt port) from directly within a GBA program running in VBA without using VBA's control 'interpreter' (for lack of knowing what they actually call it), but I could be wrong on that as I have never looked into VBA's method of using PC controllers, and I never looked for a parallel port in the GBA (which is what VBA is emulating).

#44796 - arundel - Sun Jun 05, 2005 12:02 pm

Writing a little app that detects the signals of your controller (connected via LPT) shouldn't be a big problem. Just do somthing like:

IN %reg, %port
fprint("%h", %reg)

(^^pseudo code)

That should make it possible to figure out all the signals. Don't forget that parallel ports use 3 port addrsses: data, status and control. So for the first LPT device that would be 378h, 379h and 37Ah.

However: In order for VBA to use that information you have to code some kind of interface that will be accessed by VBA in some form. So you'll need to program a device driver.

Another option would be to hack your code directly into the VBA source.

Good luck.
_________________
http://www.nausicaa.net

#44803 - tepples - Sun Jun 05, 2005 4:09 pm

"but without using any drivers"

It might make it easier for us to help you if you clarify why you can't use a driver.

If you're trying to get VBA to read an external device, the most reliable method is to install a system-wide driver. Only drivers can do the 'in' and 'out' assembly language instructions without causing an exception. There might already be a driver for your controller; search Google for NTpad XP (on Win2k/WinXP) or DirectPad Pro (on Win9x).

Or must you use a PC that you do not own? In that case, wait until you turn 18 and buy your own PC.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44814 - arundel - Sun Jun 05, 2005 7:42 pm

tepples wrote:


Only drivers can do the 'in' and 'out' assembly language instructions without causing an exception. There might already be a driver for your controller; search Google for NTpad XP (on Win2k/WinXP) or DirectPad Pro (on Win9x).


Well...there are ways to bypass this limitation. Under Linux/Unix can open /dev/io as root, thus being able to acces all the ports. Or you can use set/get_ioperm.

Under Windows OSes using the old DOS kern you can access I/O anyway. The ones that are native multiuser OSes and use the NT kern forbid accessing the I/O ports directly. However you can install a driver that re-routes your I/O read/writes so they actually get forwarded onto the bus.

But there's no real reason to hardcode keypad signals into VBA, instead of using a proper device driver.

Maybe you can tell us, why you don't want to use a driver?
_________________
http://www.nausicaa.net

#44851 - ghost Leinad - Mon Jun 06, 2005 12:13 am

why I dont want to use a driver???
because that's the point...if i use a driver mi teacher won't not accept my work

you know, windows XP forbids external access.
look, i already connected a SNES pad to the computer, then installed some drivers so i can play, well this works well.

but now im making a program just to check the signals,(some signals MUST be send), but when i press a button nothing changes, that's only can mean that my conection to my parallel port is wrong...but why is working when i install the driver???

i just want to get the signal, any signal and a diferent one for each single button, after that is easy...

this is my code so far
Code:

entrada:
    mov dx,379h
    IN  AL,DX
    mov dl,al
    mov ah,2
    int 21h
    jmp entrada


this will be checking the signal in the parallel port and then will print the signal in the screen, if i press a diferrent button the signal MUST change, but nothing happenned :(

or my code is wrong or the conection is wrong but i dont think that the conecttion is wrong so it must be the software

this is the best i can explain...thank you very much

#44865 - tepples - Mon Jun 06, 2005 6:42 am

ghost Leinad wrote:
why I dont want to use a driver???
because that's the point...if i use a driver mi teacher won't not accept my work

Can you explain the details of the negotiation with the teacher over this point? In any case, the 'in' instruction will fail.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#44920 - arundel - Mon Jun 06, 2005 7:58 pm

1. Which operating system are you using?
2. As I said before the parallel port uses three I/O port addresses. You're only reading out asingle port.
3. The base port address doesn't necessarily has to be 378h. It depends upon your BIOS settings and whether the parallel port is number 1, 2, ....
4. If you want to check for available parallel ports and their addresses from within your program you can read out the words stored at 40h:08h - 40h:0Eh.

Also you don't necessarily have to write your own program. There are apps available that will display the value of each PIN of your parallel port.
_________________
http://www.nausicaa.net

#44991 - ghost Leinad - Tue Jun 07, 2005 2:39 am

ok, here are the conclussions.

first i MUST use a external power from any kind,(5V ,i think), otherwise the devide won't work

how to solve this, well i have to use the driver to get the power from the computer, but i use the driver just to get the power not to make the device work. or you can add some power supply in one on the wires and that's all

two...the program was fine, the direction is 379h for input data.
then i just need to change the pad signal onto a keyboard signal which was easy...all games have the function to change the controls...now, as long as my program is running i can play any game i want! lol i even can use the pad to controle some letters on the notepad or word.

but let me explain the whole thing (at least i will try). the original project was make a tic tac toe game using external inputs(arcade buttons, push buttons, etz)...we are using a 8255 ppi to get all the signal we need, but we tried and tried and tried over and over again, and it just doesn't work...the time was running out and i tried to make the parallel interface, and after a while, worked....well tha's is the story...
and in the end of all, the teacher didn'd accept our project today because "he need to be at home earlier "...

thank you everybody for all your help,really, you are a very kind group of people. lol

#44994 - ghost Leinad - Tue Jun 07, 2005 2:49 am

by the way..somebody knows what happened with my tamagotchi clon(e-mach)..is my first complete game i made...lol...i sended it but i cant see it anywhere :(