#26498 - LOst? - Fri Sep 17, 2004 4:08 am
I have this code:
Code: |
int mx = x % 96;
int my = y % 96;
int sx = (x - mx) / 96;
int sy = (y - my) / 96;
|
And it runs pretty quick.... Well I can't see any differences from not having it and having it in my code when running it in my emulator collection. The question is, will this run as fast on the real hardware?
Or is my computer too fast? (4*2.2GHz Intel Xeon processors)
#26501 - jma - Fri Sep 17, 2004 4:54 am
You are dividing by a constant, which (hopefully) is being optimized into a multiply -- which is probably why is doesn't seem very slow.
Also, remember that 98% of your program's execution time is spent in 2% of the code (Knuth). Trying to optimize away a single divide, especially if your program only spends a very brief period of time doing it would be waste of effort.
Jeff
_________________
massung@gmail.com
http://www.retrobyte.org
#26505 - LOst? - Fri Sep 17, 2004 5:34 am
jma wrote: |
You are dividing by a constant, which (hopefully) is being optimized into a multiply -- which is probably why is doesn't seem very slow.
Also, remember that 98% of your program's execution time is spent in 2% of the code (Knuth). Trying to optimize away a single divide, especially if your program only spends a very brief period of time doing it would be waste of effort.
Jeff |
This is the worst thing. For some reason this commercial game I'm stealing the map from is using 12x12 blocks (96 pixels), and I have no idea how to scroll the blocks in another way
#26508 - sgeos - Fri Sep 17, 2004 6:06 am
Split them into 4 by 4 blocks? Reformat them into square 16 or 32 tile blocks?
At any rate, don't worry about speed until something is slow. If programmer time is your bottleneck, then it is more important than execution time.
-Brendan
#26509 - LOst? - Fri Sep 17, 2004 7:03 am
sgeos wrote: |
Split them into 4 by 4 blocks? Reformat them into square 16 or 32 tile blocks?
At any rate, don't worry about speed until something is slow. If programmer time is your bottleneck, then it is more important than execution time.
-Brendan |
Yea, the speed is not an issue right now. Even when I call this code every frame, it's going smooth.
And I can't split the blocks into 4 by 4 or 8 by 8. The original block maps are 12 by 12, and it would require too much to split all the blocks (appriximately 400 blocks)
#26512 - LOst? - Fri Sep 17, 2004 10:15 am
If someone of you can test this on hardware and tell me if it goes in the same speed as in an emulator:
http://www.logotypes.se/tmp/hc_act1.gba
I have programmed everything myself. I have stolen the art and level design from Sonic Advance 2's Hot Crater level since it was uncompressed in the ROM. I did it mostly to test the raster effects in the background. The foreground uses two background layers, that each call the code above (divide and modulo). Also the bg is scrolled with the (scroll_speed / 13), which would like kill everything called speed on the real hardware.
Use A button to slow down the scroll speed and B button to increase the scroll speed.
Copyright (C) Sega/Sonic Team.
#26525 - Datch - Fri Sep 17, 2004 7:29 pm
LOst? wrote: |
The question is, will this run as fast on the real hardware? Or is my computer too fast? (4*2.2GHz Intel Xeon processors) |
Maybe I don't understand something but I can't see why your computer speed would affect the division speed of the emulator. Isn't the emulator suppose to be as slow (or as fast) as the real thing to do a divide and all the other operations?
_________________
Visit SR-388 now and get a 40% discount!
#26531 - LOst? - Fri Sep 17, 2004 10:12 pm
Datch wrote: |
LOst? wrote: | The question is, will this run as fast on the real hardware? Or is my computer too fast? (4*2.2GHz Intel Xeon processors) |
Maybe I don't understand something but I can't see why your computer speed would affect the division speed of the emulator. Isn't the emulator suppose to be as slow (or as fast) as the real thing to do a divide and all the other operations? |
I hope so.
#26538 - tepples - Sat Sep 18, 2004 12:59 am
Emulators that use a BIOS file dumped from your GBA should take roughly as long to divide as the real thing, but some emulators don't use a BIOS file because many users don't have a GBA and a multiboot cable. Instead, those emulators perform "high level emulation" of the BIOS in natively compiled C code, and some don't even bother to estimate the number of CPU cycles that each BIOS routine eats.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#26542 - Krakken - Sat Sep 18, 2004 1:33 am
Try it on NO$GBA. That should give you a very accurate result.
#26548 - LOst? - Sat Sep 18, 2004 4:04 am
tepples wrote: |
Emulators that use a BIOS file dumped from your GBA should take roughly as long to divide as the real thing, but some emulators don't use a BIOS file because many users don't have a GBA and a multiboot cable. Instead, those emulators perform "high level emulation" of the BIOS in natively compiled C code, and some don't even bother to estimate the number of CPU cycles that each BIOS routine eats. |
But I don't use the divide routine from the BIOS.
And what is NO$GBA?
#26549 - Krakken - Sat Sep 18, 2004 4:29 am
http://nocash.emubase.de/gba.htm
Some official developers use this emulator too.
#26550 - LOst? - Sat Sep 18, 2004 5:01 am
Krakken wrote: |
http://nocash.emubase.de/gba.htm
Some official developers use this emulator too. |
I tried it, and my engine locks up at one place. Does that mean it will lock up on the real hardware too?
It looks up on a divide. If I change it to >> it will work.
#26551 - SmileyDude - Sat Sep 18, 2004 5:06 am
LOst? wrote: |
I tried it, and my engine locks up at one place. Does that mean it will lock up on the real hardware too? |
Well, no emulator is completely perfect -- but, from what I've heard, NO$GBA is about as close to perfection as you can expect. If it locks up there, there is most likely a bug that will either manifest itself as a lock up on real hardware, or worse, a subtle bug that will cause you endless pain.
_________________
dennis
#26552 - LOst? - Sat Sep 18, 2004 5:41 am
Well, the ROM is updated, so it won't hang in NO$GBA. So if anyone wants to test it on the real hardware for me, then thank you really much!
http://www.logotypes.se/tmp/hc_act1.gba
#26553 - Krakken - Sat Sep 18, 2004 8:10 am
It works fine on hardware.
#26554 - LOst? - Sat Sep 18, 2004 9:24 am
Krakken wrote: |
It works fine on hardware. |
Great to hear! Thank you very much!
#26559 - dagamer34 - Sat Sep 18, 2004 4:24 pm
It runs very nicely on real hardware using my EZFA. Especially the raster effects. I like it! :)
_________________
Little kids and Playstation 2's don't mix. :(
#26570 - LOst? - Sun Sep 19, 2004 3:05 am
dagamer34 wrote: |
It runs very nicely on real hardware using my EZFA. Especially the raster effects. I like it! :) |
Yay! Thank you!
This really helps me to start my game development for sure! And I'm going to invest in a GBA flash cart so I can bug check myself in the future.