25 April 2018, 00:58 | #1 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Trying to implement joystick code in my stuff
Hi guys,
I've been pulling my hairs out for a while trying to implement JOTD's CD32 pad reading code into my own code. This seems like an absolute n00b mistake but I can't figure it out even after contacting JOTD and following his instructions (which I might have followed wrong, granted). You can find the original code in JOTD's CD32Load archive: http://jotd.pagesperso-orange.fr/amiga.html The file I am trying to implement is called "ReadJoypad.s" I am using Devpac 3.18 The error I get is the following: Code:
Error: undefined symbol at line 70 in file READJOYPAD.S 70 01.0000002E 41F900000007 lea _custom,a0 Error: undefined symbol at line 71 in file READJOYPAD.S 71 01.00000034 43F900000005 lea _ciaa,a1 2 errors found Second suggestion was that those symbols weren't in the includes, which they are not, which is weird, because these are the official includes as far as I understand. Anyway, he told me to include them manually: Quote:
Code:
ciab EQU $BFE001 Code:
custom EQU $DFF000 (note: i also tried ciaa EQU $BFE001, I noticed probaby JOTD made a mistake there. Still the same problem) I also tried adding both on my code after the includes instead, and then it tells me: Code:
Error: symbol defined twice at line 35 in file test.S 35 01.0000010C custom EQU $DFF000 1 error found Can anybody kick this absolute moron in the right direction? I'm totally confused. |
|
25 April 2018, 01:30 | #2 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
Quote:
_custom EQU $DFF000 |
|
25 April 2018, 01:34 | #3 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
The ReadJoypad.s from jst_6.0.zip on JOTD's home page seems different, as line 70 and 71 don't reference _custom and _ciaa. So I don't know what you assembled.
BTW, did you notice that the undefined symbols have a leading underscore? Your EQUs don't. Another option is to link with amiga.lib, which should export these symbols as well. |
25 April 2018, 15:40 | #4 | |||
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Oh man I missed the underscore! I just copy pasted from JOTD's message.
Is the address for _ciaa ok or is it wrong? $BFE001 ? Quote:
I didn't know the JST one also had this code, I can try that instead! Thanks! Quote:
Quote:
Thanks a lot! Sorry, I am a TOTAL NOOB. |
|||
25 April 2018, 21:44 | #5 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
Quote:
|
|
26 April 2018, 22:37 | #6 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
amiga.lib is included in all official NDKs, and also comes with most compilers, sometimes with slightly modified versions. But amiga.lib should always define symbols like _ciaa, _custom, etc.
It's easier in assembler to include hardware/custom.i or cia.i before linking with amiga.lib, though. |
03 May 2018, 00:50 | #7 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
OK I don't get this error anymore, but now when I include JOTD's code in my code, I can't launch the game.
All I get is being sent back to the prompt. No guru, no anything :/ I'm really way over my head here, unable to debug what is going on here. Any help appreciated. |
07 May 2018, 11:54 | #8 | |
Registered User
Join Date: Jul 2015
Location: The Netherlands
Posts: 3,406
|
Quote:
Where in your do you include the ReadJoyPad.s? If it is at the top of the file, the assembler will put the code in front of yours during assembly (include can be seen as the assembler just dumping the content of whatever file you include at the point where you write the include command). In that case, the program will start executing whatever ReadJoyPad.s starts with and it's possible that the code at the start of ReadJoyPad.s just so happens to return without incident, which results in ending your program before it reaches your code. If this is the actual problem and you wish to prevent it, you have to either use the include command later in your file or make your source consist of two separate files that you link together using a linker. |
|
07 May 2018, 16:12 | #9 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Quote:
Why does this have to be so weird? I guess I am too used to stuff like C :/ I actually have no idea where to put it, then, or how to fix this. Actually what I realized is that I couldn't find anywhere in JOTD's CD32Load or JST code, any reference to where ReadJoypad.s is included. I Searched the source for "Readoypad.s"and NOTHING turned up. So maybe he "linked" it as you said? I have no idea what i am doing here, I just wanted to include the CD32 joypad reading code in my own game and I thought it'd be as easy as including it in the source |
|
07 May 2018, 16:50 | #10 | |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
Quote:
|
|
07 May 2018, 17:10 | #11 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
mcgeezer I might take you up on this when I am ready to give up. I am pretty stubborn and determined to learn how to do this haha
I appreciate everyone's help really very much! My first guess is that I will put this near where I want the actions to happen when keys/joystick stuff are pressed. Then see what happens. Maybe ReadJoypad.s needs modifications to be included how I want to include it? Can anyone tell from the code posted above? |
07 May 2018, 17:25 | #12 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
Quote:
Quote:
Code:
jmp start include readjoypad.s start: You have to understand that unlike C, the entry point in ASM is at the start of the program. Therefore if you include something, any code in it will get executed before your program. System includes are harmless because they contain no code, just constant definitions. But contrary to C or many other languages, in ASM you don't have to declare a routine before using it. So you can include it anywhere it will not annoy. I recommend doing that right after your normal code. |
||
07 May 2018, 17:49 | #13 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Quote:
I understand how this works now, and will try to do better! Will report back with findings. |
|
07 May 2018, 18:40 | #14 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
|
08 May 2018, 23:37 | #15 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Including files which generate code or data is also not a nice practice, IMHO. Includes should only contain definitions (equates, macros). When you do that anyway, you have to be sure that there are no symbol conflicts with the included file.
The good way would be to assemble ReadJoypad.s into an object file, export the symbols you need, and use a linker to link it with your project into the final executable. It also makes building your project much faster, because you don't have to assemble it together with your code every time. |
09 May 2018, 00:27 | #16 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Is there any guide anywhere that explains how to make an OBJ and how to link together?
Also keep in mind I use Devpac, not a newfangled cross assembler. |
09 May 2018, 07:26 | #17 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Includes can and should contain any kind of code. For example, I include the complete system-kill/startup code at the top of my source which makes it much more readable as the startup code is neatly hidden and not interesting to look at anyway when coding effects. Same for various helper routines and other things. Why bloat the source with "standard" code when it can be easily included?
|
09 May 2018, 08:29 | #18 | ||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
Quote:
Using a linker has a small issue, it is that you'll generate slightly suboptimal code because some information (some of the offsets) will not be known at assembly time and therefore the assembler can't use its full peephole optimization power (not a big issue on Devpac, ok ). Quote:
I pushed that system up to the point there aren't any OS calls / hardware accesses directly in my code anymore |
||
09 May 2018, 15:55 | #19 | |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,644
|
Quote:
If I had this my way, I'd do as meynaf described, and reserve my main chunk of code for just the logic of what I need to do with the specific program itself. I don't like the "chuck all code in one file" approach that was common in demomaking in the 90s. This is tidier to me, but I need to know how to do it. Then again, from what I described above, I feel like JOTD might have linked it anyway, because as I said there's no reference to any including of this file in any of the files in the source pack. |
|
09 May 2018, 18:48 | #20 |
Registered User
Join Date: Oct 2017
Location: Sunderland, England
Posts: 2,702
|
I have a lot of includes in my game, without them the code would be unmanageable.
The way I do it now is split the code into secions i.e "input.asm" and any variables I put in an assoicated dat file like "input.dat". I then group the includes together at the start of the code and put the dat's at the end, that way I can use an address register in the centre of the dat's to use relative addressing of variables in a 64K range. (thanks Galahad for the addressing tip) Happy to give an example if you like. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
implement others 68000 machines ? | turrican3 | support.WinUAE | 28 | 23 November 2017 00:54 |
Joystick reading code | borchen | Coders. Asm / Hardware | 57 | 23 November 2014 14:08 |
Req: Tanks 'n' Stuff Src Code | kevingpo | request.Old Rare Games | 1 | 07 July 2003 12:07 |
Should I implement PM download now ? | RCK | project.EAB | 12 | 08 January 2002 01:21 |
|
|