WIP Air Hockey (need help)

Use this forum to share and discuss Uzebox games and demos.
User avatar
omundodogabriel
Posts: 33
Joined: Mon Mar 18, 2013 9:07 pm
Location: Brazil
Contact:

WIP Air Hockey (need help)

Post by omundodogabriel »

Image
This is my second try at the Pong source. This time i decided to modify the engine a bit and make a air hockey game. Remember the table Air Hockey games? Yeah, now you can play on the Uzebox too... :D

This is the first Beta, i have some problems with the game right now, and need some help to fix.
First, the game have slowdowns during gameplay, and sometimes de sprites flicker too. I think is a kernel related problem, anyone know how to fix? Or maybe Uzebox is too weak to handle this?

Controls:
Start - Will start the game
Select - Go back to menu when is ingame
B - Move fast

The first player to score 7 points win!

Like always, sorry for my bad english...
DOWNLOAD Beta 1 and sources
Attachments
Air Hockey_src.zip
(128.85 KiB) Downloaded 466 times
AirHockey.hex
(72.31 KiB) Downloaded 508 times
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP Air Hockey (need help)

Post by uze6666 »

Nice, Air Hockey!

Hmmm...you have no WaitVsync(1); in you main loop and code run way too often and, ironically, this will slowdown the game. There's is no point in running the main loop more than 60hz, the screen refresh rate. So fix this with:

Code: Select all

		}else{
			WaitVsync(1);
			ProcessScore();
			ProcessControls();
			ProcessPaddles();
			ProcessBall();
			MoveSprites();
		}
As for the flickers this is caused by not having allocated enough ramtiles. Your sprites are 2x2 which means at most 9 ramtiles are required depending of the x/y offset of the sprite. 9 ramtiles x 3 moving objects means you need 27 ramtiles to avoid flickers.

Here's a hex with the fixes:
AirHockey.hex
(71.25 KiB) Downloaded 570 times
Looking forward the final release! :)
User avatar
Kilo
Posts: 330
Joined: Wed Dec 19, 2012 3:43 pm
Location: AC, Germany

Re: WIP Air Hockey (need help)

Post by Kilo »

wow, nice!!! Air Hockey!
I guess it's for two players, right?
The last digit of Pi is 7! I calculated this, as I counted to infinity yesterday!
User avatar
omundodogabriel
Posts: 33
Joined: Mon Mar 18, 2013 9:07 pm
Location: Brazil
Contact:

Re: WIP Air Hockey (need help)

Post by omundodogabriel »

uze, the hex you provided is running smooth :D thanks....
But i'm having problems trying to implement the changes you say, i changed de -DRAM_TILES_COUNT on kernel flags to 27, and added the WaitVsync(1); to the main loop, but now the game is crashing every time, and random bugs like color changes and duplicated sprites is ocurring :(

I attached the hex that I compiled with these changes ...

Can you upload your modified code please?
Attachments
AirHockey_bug.hex
(72.32 KiB) Downloaded 468 times
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP Air Hockey (need help)

Post by uze6666 »

Weird, those issues are typical when you use too much ram. I'll send the code tonight. In the mean time, can't you post your platform and gcc version. Also if you can post a dump of the build log, specially the part about memory use, that would help.
User avatar
omundodogabriel
Posts: 33
Joined: Mon Mar 18, 2013 9:07 pm
Location: Brazil
Contact:

Re: WIP Air Hockey (need help)

Post by omundodogabriel »

uze6666 wrote:Weird, those issues are typical when you use too much ram. I'll send the code tonight. In the mean time, can't you post your platform and gcc version. Also if you can post a dump of the build log, specially the part about memory use, that would help.
Okey ;)

Memory usage:

Code: Select all

AVR Memory Usage
----------------
Device: atmega644
Program:   26324 bytes (40.2% Full)
(.text + .data + .bootloader)
Data:       3783 bytes (92.4% Full)
(.data + .bss + .noinit)
Using: WinAVR-20100110 + Atmel STUDIO 6 on Windows 7, gcc 4.3.2
uzem v1.15

The memory usage is almost full, the extra ramtiles made RAM overflow? :?
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP Air Hockey (need help)

Post by uze6666 »

Here's the project.

Interestingly, the memory stats are different on my side, and I use more RAM! Same WinAVR version. :shock:

Code: Select all

AVR Memory Usage
----------------
Device: atmega644

Program:   25010 bytes (38.2% Full)
(.text + .data + .bootloader)

Data:       3944 bytes (96.3% Full)
(.data + .bss + .noinit)
Attachments
AirHockey.zip
(216.8 KiB) Downloaded 468 times
User avatar
omundodogabriel
Posts: 33
Joined: Mon Mar 18, 2013 9:07 pm
Location: Brazil
Contact:

Re: WIP Air Hockey (need help)

Post by omundodogabriel »

Compiled the sources with your modifications, i just modified the kernel path, and still with the bug :( But i think i found the bug, you changed the kernel path, your kernel is probably another version? I will try with the original kernel and see what happens... :?

Edit:
Just used the old kernel from the pong sources and the game worked just fine :D The problem was the last kernel i updated...
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: WIP Air Hockey (need help)

Post by uze6666 »

Oh yes, kernel version..should have asked. I used the latest version from the trunk. It is very stable and the most optimized so far, I'd recommend you use this one if it doesn't cause problems.
User avatar
omundodogabriel
Posts: 33
Joined: Mon Mar 18, 2013 9:07 pm
Location: Brazil
Contact:

Re: WIP Air Hockey (need help)

Post by omundodogabriel »

uze6666 wrote:Oh yes, kernel version..should have asked. I used the latest version from the trunk. It is very stable and the most optimized so far, I'd recommend you use this one if it doesn't cause problems.
I thought the version that was in "uzebox_src_3.3" was the last, but I found that not. I downloaded the latest SVN version and is working perfectly. I even recovered a lot of ram! Thanks Uze! Tomorrow I'll continue working on AI and improving the title screen.

look the new memory usage:

Code: Select all

		AVR Memory Usage
		----------------
		Device: atmega644
		Program:   25928 bytes (39.6% Full)
		(.text + .data + .bootloader)
		Data:       3234 bytes (79.0% Full)
		(.data + .bss + .noinit)
Thanks!!!
Post Reply