Looking for sample code
- UndeadDC
- Insane DCEmu
- Posts: 110
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Aug 11, 2005 9:26 pm
- Has thanked: 4 times
- Been thanked: 0
Looking for sample code
I'm looking for some sample code or open source game code that showcases the use of KOS really well, preferably something that has decent comenting Is there a sourceforge page or something where I could download some stuff? It just now occured to me that the homebrew page would probably be a good place to look also, but if any of you could point me to something that specificaly uses KOS, I would really appreciate it.
- UndeadDC
- Insane DCEmu
- Posts: 110
- Joined: Thu Aug 11, 2005 9:26 pm
- Has thanked: 4 times
- Been thanked: 0
Could someone give me an example of what to type into cygwin in order to compile one of the kos examples? I realize this is an odd request, but I'm trying to learn Cygwin/bash, GCC, and kos all at the same time, and I think it would help a lot if I had a jumping off point I could work from. I'm using LyingWakes awsome self building distro that puts you at
me@computer /usr/local/dc/kos1.3/kos
when you start the program. Thanks.
me@computer /usr/local/dc/kos1.3/kos
when you start the program. Thanks.
- UndeadDC
- Insane DCEmu
- Posts: 110
- Joined: Thu Aug 11, 2005 9:26 pm
- Has thanked: 4 times
- Been thanked: 0
I get,
bash: make: command not found
I also tried,
$ gcc hello.c -o hello
and got,
bash: gcc: command not found
edit:
Now that I'm beginning to understand what a weird pain in the butt compiling with gcc is I don't feel so silly about asking for this. Thanks to the home of the hitmen I'm getting closer, but I'm still not there yet
$ sh-elf-gcc -m4 hello.c -o hello
hello.c:7:17: kos.h: no such file or directory
hello.c:10: error: parse error before "romdisk"
hello.c:10: warning: data definition has no type or storage class
hello.c:24: error: parse error before '|' token
.......etc.
any takers?
bash: make: command not found
I also tried,
$ gcc hello.c -o hello
and got,
bash: gcc: command not found
edit:
Now that I'm beginning to understand what a weird pain in the butt compiling with gcc is I don't feel so silly about asking for this. Thanks to the home of the hitmen I'm getting closer, but I'm still not there yet
$ sh-elf-gcc -m4 hello.c -o hello
hello.c:7:17: kos.h: no such file or directory
hello.c:10: error: parse error before "romdisk"
hello.c:10: warning: data definition has no type or storage class
hello.c:24: error: parse error before '|' token
.......etc.
any takers?
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
If you're not using the Makefile, you'll need to create romdisk.o manually:
Then you'd need to link romdisk.o along with main.c:
Both genromfs and bin2o are in the KOS utils directory.
-Sam
Code: Select all
genromfs -f romdisk.img -d romdisk -v
bin2o romdisk.img romdisk romdisk.o
Code: Select all
kos-cc main.c romdisk.o -o test.elf
-Sam
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
It most probably output an elf file, but you can check by running. It should say something like "ELF 32-bit LSB executable, Hitachi SH, version 1 (SYSV), statically linked". You can convert that to a bin file with
Then, if you want to be able to boot from a CD, you need to scramble the binary file and name it 1ST_READ.BIN.
-Sam
Code: Select all
file hello.file
Code: Select all
sh-elf-objcopy -O binary -R .stack hello.file hello.bin
-Sam
- UndeadDC
- Insane DCEmu
- Posts: 110
- Joined: Thu Aug 11, 2005 9:26 pm
- Has thanked: 4 times
- Been thanked: 0
OK, I decided before I went any further I would get cygwin running like it should (I was having trouble with more than just make). Everything seems to be working peachy now, but will I need to create makefiles for programs I write? If so, can I just edit the makefiles in the examples some how? I'm assuming the big pile of stuff right after the kos-cc line is the the helper script mentioned by c99koder in an earlier post and the last line, "bubbles.o -lparallax -lgl ...etc" is the linker. Finally, what does this line do:
rm -f bubbles.elf
edit: Concerning the line where the libraries are linked to the object file what is '--start-group' and '--end-group' for? I can't find any info on it in my documentation. And assuming the .elf file is the final output file how is it created or modified after the final linking is done to the object file? There aren't any commands after that. Does it have something to do the line I mentioned above?
That's all for now I guess Anybody know where to get documentation on make?
rm -f bubbles.elf
edit: Concerning the line where the libraries are linked to the object file what is '--start-group' and '--end-group' for? I can't find any info on it in my documentation. And assuming the .elf file is the final output file how is it created or modified after the final linking is done to the object file? There aren't any commands after that. Does it have something to do the line I mentioned above?
That's all for now I guess Anybody know where to get documentation on make?
Last edited by UndeadDC on Sun Nov 27, 2005 7:59 pm, edited 1 time in total.
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
Which makefile are you looking at? The only time I see rm in the parallax bubbles example is in the "clean" rule, which is used to erase everything you've compiled.
You can find Make's documentation at http://www.gnu.org/software/make/manual/make.html
-Sam
You can find Make's documentation at http://www.gnu.org/software/make/manual/make.html
-Sam
- UndeadDC
- Insane DCEmu
- Posts: 110
- Joined: Thu Aug 11, 2005 9:26 pm
- Has thanked: 4 times
- Been thanked: 0
It's the bubbles example I'm looking at. Before the kos-cc line is run rm is run to erase bubbles.elf. Is this done to clean the file before a new compile is done? I'm thinking that's what you meant, but I just want to be sure.c99koder wrote:Which makefile are you looking at? The only time I see rm in the parallax bubbles example is in the "clean" rule, which is used to erase everything you've compiled.
You can find Make's documentation at http://www.gnu.org/software/make/manual/make.html
-Sam
Again, thanks for all your help. You don't know how much I appreciate it.
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
Ah, that's actually in a different section. Here's a quick intro Makefiles:
Makefiles are basically a set of rules and dependancies. When you run "make" by itself, it will execute the first rule it finds. Rules are all the way at the left of the file (not indented), and commands that are part of that rule are indented with 1 tab. So here's a really simple Makefile:
When you run "make", it will execute the first rule (hello), and run the echo statement.
Now, in the bubbles Makefile, there are several rules. The first one, "all", is what make will execute if you just run "make". It says "all" depends on "rm-elf", and "$(TARGET)" which is bubbles.elf (declared at the top). So basically, when you run "make", it will first execute the "rm-elf" rule, followed by the bubbles.elf rule. Doing it this way will force make to re-link your binary even if none of your C files have changed. Make will see that bubbles.elf is missing (because it deleted it), and then run the rule to create it again.
There are several other rules defined in that Makefile: "run", and "dist". If you wanted to use one of those, you would call "make run" or "make dist" (you can also call "make clean" to run the clean rule, which deletes all your object files). According to the makefile, "make run" is the same as running "dc-tool -x bubbles.elf", and "make dist" will delete all your object files and then strip the binary of any debugging symbols.
I know I'm not the best at explaining things, so let me know if you need anything clarified
-Sam
Makefiles are basically a set of rules and dependancies. When you run "make" by itself, it will execute the first rule it finds. Rules are all the way at the left of the file (not indented), and commands that are part of that rule are indented with 1 tab. So here's a really simple Makefile:
Code: Select all
Hello:
(tab)echo "Hello world!"
Now, in the bubbles Makefile, there are several rules. The first one, "all", is what make will execute if you just run "make". It says "all" depends on "rm-elf", and "$(TARGET)" which is bubbles.elf (declared at the top). So basically, when you run "make", it will first execute the "rm-elf" rule, followed by the bubbles.elf rule. Doing it this way will force make to re-link your binary even if none of your C files have changed. Make will see that bubbles.elf is missing (because it deleted it), and then run the rule to create it again.
There are several other rules defined in that Makefile: "run", and "dist". If you wanted to use one of those, you would call "make run" or "make dist" (you can also call "make clean" to run the clean rule, which deletes all your object files). According to the makefile, "make run" is the same as running "dc-tool -x bubbles.elf", and "make dist" will delete all your object files and then strip the binary of any debugging symbols.
I know I'm not the best at explaining things, so let me know if you need anything clarified
-Sam
-
- Elysian Shadows Developer
- Posts: 1876
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 82 times
- Been thanked: 64 times
- Contact: