19 October 2013, 16:57 | #1 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
First doubts for game developing
Hi all,
I'm new to this forum and, first of all, I want to say thanks to Photon for his amazing tutorial on Youtube. I'm starting to develop for the Amiga in asmOne and trying to make a very simple game. I would like to ask a couple a questions, and would be very grateful for any help given: - Which is the best approach for doing things during the VBI? I mean: is it better waiting for the raster or using the VBL interrupt? - Right now, my main problem is how to handle key presses. I think there are two options for this: interrupt or a device handler? Am I right? Which are the best options for both points (VBI waiting and handling key presses) considering that I'm developing a game? Thanks in advance!!! |
19 October 2013, 19:55 | #2 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
Welcome,
I am very much noob myself at this but I'll try to answer. First, you second question...Read this thread http://eab.abime.net/showthread.php?t=70691 In it, you'll find two zip files. On the first zip, I've implemented reading the keyboard with an interrupt. On the second zip, I've implemented reading the keyboard with an input handler. (Bear in mind the fist zip is buggy, but not cause of the keyboard handling Now, you first question. Most of the time, you can freely choose, I guess. But say, as the topic of the thread I linked was, you want to do data background loading from disk while your game still runs, you have to put the game stuff on VBL (and handle the loading in the main loop code) |
19 October 2013, 23:19 | #3 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
Personally I just read the keyboard status directly using the CIA registers. It might not be the proper way to do it but it's simple and it works.
|
20 October 2013, 15:40 | #4 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
@Alkis Thanks for your answer. In fact, 2 or 3 days ago I spent some hours trying to understand the code of your second example (input handler) but I was unable to get very far. A little bit too complex for me at this moment. I will have a look at your other file (interrupt) and try to compare both .
@Mrs Beanbag I didn't know this third way of looking at this problem. Thanks! Still looking for the simplest possible to handle key presses for a game. Thanks again and, please, keep on posting replies! |
21 October 2013, 11:18 | #5 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
First you have to make a decision if you want to write your game with or without using the OS. Mixing direct hardware banging with OS calls is a bad idea.
You can do the VBL and keyboard handling as you like, as long as it works. I decided to run the whole game's main engine during a VERTB interrupt, as I want to run it at full 50 fps anyway. For keyboard handling I decided to install a Level 2 interrupt handler, because key presses occur very rarely. So I don't want to spend any cycles polling the CIA-state when not necessary. |
21 October 2013, 13:27 | #6 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Can anyone explain briefly the differences (pros and cons) between handling key presses as an interrupt and using an input device handler, please? @alkis?
@phx Thanks! You say you do all the game stuff in the VERTB interrupt so to have the game running at 50 fps, I love that! But I have a question: what would happen if the instructions executed during the VBI take longer than the VBI iteself? What would be the effects? |
21 October 2013, 14:13 | #7 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Quote:
But there is also the IPL mask in the CPU's SR register, which might still mask all level 3 interrupts. It is not reset before RTE. This would mean that you will never be interrupted again, but an already cleared VERTB interrupt request will be reset at the end of your routine and the next interrupt happens directly thereafter. Otherwise (flag was not cleared), the interrupt is lost. Sorry, I'm a bit confused without any documentation here at work. Please, anybody correct me... |
||
21 October 2013, 15:50 | #8 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
|
21 October 2013, 16:18 | #9 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,553
|
New interrupt starts only if new interrupt level is higher than current SR stored interrupt level. Only level 7 interrupt can interrupt another level 7 interrupt.
|
21 October 2013, 17:14 | #10 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Thanks Toni. So probably my second paragraph is right?
IPL is 3 when a VERTB IRQ happens, until I lower priority with RTE. If I cleared the VERTB-flag in INTREQ, at the beginning of my routine, and the next VERTB happens before RTE, then the interrupt is caused directly after it? Otherwise it is lost. Is that correct? |
21 October 2013, 17:39 | #11 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
Quote:
Unfortunately, I don't have the knowledge for this. Let's hope someone with the know-how steps in.... |
|
22 October 2013, 14:02 | #12 |
Registered User
Join Date: Sep 2008
Location: Germany
Age: 49
Posts: 138
|
Commodores' input.device 'knows' about all the different keyboards you find within the Amigas. See http://eab.abime.net/showthread.php?t=71099
|
23 October 2013, 00:27 | #13 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Wow, thank you so much for all your answers!
After getting so much information I've decided to enter for a while in "guru meditation" mode and think about all the possible options available:
|
23 October 2013, 00:37 | #14 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
you could use a copper interrupt, there is an interrupt assigned for the copper to use which you can trigger from the copper list on any raster line you want.
|
23 October 2013, 11:17 | #15 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
The keyboard transmits an up/down flag with each key-code (called IECODE_UP_PREFIX in the Input Handler). It is set when the key was released. This helps you to keep track of the current state of each key you are interested in.
|
23 October 2013, 11:19 | #16 | |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,553
|
Quote:
What do you mean by lost? You only "lose" interrupts if you clear INTREQ at the end of routine and your routine took longer than 1 vblank. (and yuo can only lose/miss interrupts that are not caused by external devices like CIA or HD controller) |
|
23 October 2013, 14:59 | #17 | |||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Quote:
Quote:
I would say that the VERTB IRQ is the only one I could miss. Even a level 2 CIA-A interrupt would still occur, as soon as RTE lowers the IPL-mask in SR below 2. |
|||
23 October 2013, 21:07 | #18 | ||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,553
|
Quote:
Quote:
(There are some programs that do it wrong, clear INTREQ first and then clears CIA interrupt register and have extra code that handles and ignores the extra interrupt!) |
||
24 October 2013, 12:23 | #19 | |
Registered User
Join Date: Dec 2007
Location: Dark Kingdom
Posts: 213
|
Quote:
To be sure, you need to access a custom register or a CIA register (read accesses are enough) *after* the write to INTREQ. |
|
25 October 2013, 09:43 | #20 |
Fernando Cabrera
Join Date: Oct 2013
Location: Spain
Posts: 106
|
Thanks again for all your help!
Could anyone please tell me the number of the last visible line in a low resolucion / non interlaced PAL display? Amiga HRM says that total number of lines in that case is 312, 256 of which are really visible. That means there are 56 non visible lines. Does that mean there are 28 lines before the first visible line and 28 after the last visible line? In that case line 28 + 256 = 284 would be the last line visible. Thanks in advance! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
some doubts on the rom (kickstart) management in rommgr.cpp | pucci | support.WinUAE | 2 | 11 September 2011 14:42 |
Developing a versus fighter for the OCS | CMA Death Adder | Coders. General | 41 | 15 April 2011 16:16 |
Playpower - 8 bit learning games for the developing world | girv | Retrogaming General Discussion | 5 | 24 March 2009 22:00 |
[Found: Biplane Duel] Plane Flying Game, 2D, Shoot each other (Compilation game?) | EssKung | Looking for a game name ? | 7 | 18 May 2007 23:37 |
Who are developing games for Amiga platform at the moment? | oldpx | Amiga scene | 65 | 06 October 2002 17:41 |
|
|