22 February 2017, 12:08 | #21 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
After a 1-year hiatus which started with the birth of my daughter, I'm getting back into Amiga programming again.
I have a newbie question: What's the best way to take over the Amiga keyboard in C? In GameSmith's examples, they have this nasty looking code: Code:
// BAD PRACTICE ALERT! ptr to hardware keyboard reg unsigned char *keybrd=(unsigned char *)0xbfec01; unsigned char key; . . . key = *keybrd; // escape key pressed if( key == 0x75 ) return(1); So what's the correct way? |
22 February 2017, 12:36 | #22 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
One way is to open a RAW: device and get the key presses from there.
|
22 February 2017, 13:30 | #23 | |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 44
Posts: 4,190
|
C++ is probably optimistic for the Amiga although it would be very nice to have a decent C++ compiler. Many people seem to think that C++ is inferior to C performance-wise however I disagree. It offers some convenient features but if used correctly it will create as efficient code as well-written C but should be easier to maintain and avoid bugs in your code. One feature I particularly enjoy with C++ apart from OOP are vectors which are a convenient and very efficient way of creating dynamic arrays without having to worry about memory leaks since all memory are automatically deallocated when it goes out of scope.
There is also the Hisoft C++ compiler for Amiga however I don't know how good it is. I have tried SAS/C and it does not do C++ out of the box. Rather use a decent ANSI C compiler though than a bad C++ one. Quote:
I think this documentation should cover it: http://amigadev.elowar.com/read/ADCD.../node00FE.html Edit: How about just using getchar()? System keys like keyboard shortcuts will be filtered and not received by your program but if you want full access, you probably need to to bang the hardware directly. Last edited by demolition; 22 February 2017 at 13:41. |
|
22 February 2017, 16:28 | #24 | ||
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
Quote:
Vectors would be nice to have though. I'm working on a smaller game to get me going again and because it's a fixed play-area, I've got away without any dynamic allocation at all. It's sort a sort of Tetris-y/Columns type game I guess (but different) and to drop tiles in place I'm just doing a memcpy() to "playarea[row][col].bob" when something changes. I don't know if this is necessarily the right idea, but it works. Quote:
|
||
22 February 2017, 16:41 | #25 |
Unregistered User
Join Date: Sep 2012
Location: Copenhagen / DK
Age: 44
Posts: 4,190
|
Even without the need for dynamic memory allocation, vectors is still a nice way to ensure that all memory are freed properly no matter how the program terminates. When using malloc() or similar allocation methods, this may not always be the case unless Amiga OS has some kind of cleanup method from a crashed process? Perhaps this is not too relevant on Amiga since a program crash will normally just show the reboot/suspend requester and in suspend mode, the memory will never be freed. My experience with Amiga programming is quite limited and I may be spoiled by modern compilers and OSs.
|
22 February 2017, 17:50 | #26 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,200
|
Storm C versions prior to 4 are too buggy. Storm C 4 is just GCC. If your 2d array is global or static local the compiler will deallocate it for you at the end so no worries.
|
23 February 2017, 11:38 | #27 |
Computer Nerd
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 48
Posts: 3,840
|
Another way is to use IDCMP messages from a window. In a full screen game you'd open a screen, open an invisible window the size of the screen, and use a wait message loop to get the IDCMP messages. You can also get mouse input etc like that.
Has one big drawback: You'll need multi threading. |
24 February 2017, 11:10 | #28 | |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
Quote:
I think I will need to open some kind of invisible window to "soak them up". Samurai_Crow mentioned a RAW: device, which I read is a variation of the console which has unbuffered keypresses so I'm hoping that will work. EDIT: I just found some code in the RKM that might help - "Using the Console Device Without a Window". In other news, I used a RastPort for the first time to write a make-shift scoreboard. That one turned out to be dead easy. At times learning this stuff has been like wading through treacle, so It's great when that happens! |
|
19 March 2017, 22:45 | #29 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
Time for a screenshot. The game is called Landfill. It's a little like Tetris or Columns but also different from either and unique as far as I know, but more on that later... The gameplay is done so it's all polishing up now. I'm very happy with it. It's the first game I've written that I find myself sitting down with to try and beat my high score, so that's got to be a good sign. What do people think of the background on the left? People I've shown it to seem to like it but would something more stylised or cartoony work better? I've just seen Lumberjack on the Amiga and I feel that's the level of presentation I need to aim for. |
20 March 2017, 23:48 | #30 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
The lack of response probably confirms what I knew deep down - the presentation isn't good enough right now.
I need to create a new background that properly integrates the playarea, scoreboard, etc. Possibly I'll turn it into a two-player game. The reason the play-area is so basic is that I'm drawing it with the rastport so I can have different size playareas for different game modes, but I might need to lose that feature. I like the blocks/tiles but the rest needs to go up a level or two. It's funny that after setting Lumberjack as a benchmark, I read some guy describe this unreleased game as mediocre shovelware and that they would struggle to give it 1 out of 5 in a PD review. I know people think what they say doesn't matter but it's actually quite demotivating to read stuff like that. I've also just spent a whole evening trying to blit out a double-size version of the tiles and hit a brick wall. The image is there but the colours are wrong as if a bitplane is missing. I'm pretty new to pointer arithmetic and bitwise operations in and I need to stop now because I'm tying myself in knots. All in all I'm going to bed on a bit of downer but tomorrow's another day and it's back to PPaint... Last edited by clebin; 20 March 2017 at 23:56. |
21 March 2017, 12:10 | #31 |
Registered User
Join Date: Aug 2012
Location: RAM:
Posts: 83
|
I like the artwork style Keep at it!
|
21 March 2017, 13:08 | #32 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,356
|
Yes, the backdrop looks like a nice Licenceware game.
|
21 March 2017, 20:06 | #33 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
@attle, idrougge
Thanks both! Really appreciate the feedback. I'll play around with some less drastic changes. |
21 March 2017, 23:43 | #34 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
Quite a productive evening - I kept the background but added this old wooden TV with an LED-style display for the score.
|
22 March 2017, 02:16 | #35 |
Registered User
Join Date: Nov 2014
Location: Norway
Posts: 388
|
Its kinda hard to judge gameplay based on a still picture, and thats my guess why there has been a lack of feedback so far.
I notice you compare it somewhat with Tetris, and thats encouraging, cause brainteaser games is always fun to play. |
22 March 2017, 05:44 | #36 |
Registered User
Join Date: Feb 2014
Location: Warszawa / Polska
Posts: 1,862
|
It looks awesome I would love to play Your game.
|
22 March 2017, 09:22 | #37 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
@Gzegzolka
Thanks mate, that's nice to hear! Cheers - that makes sense. I've got one in-game pop-up to add and then I'll record a video. That'll explain the gameplay better than I can! |
22 March 2017, 17:11 | #38 |
Registered User
Join Date: Feb 2014
Location: Warszawa / Polska
Posts: 1,862
|
Clebin, I do not know why You do not receive more positive response. In my case - I do not have now much spare time, and if I have I play lumberjack. Also I do not think that Your game lacks presentation. Graphics looks very nice, even if it's still picture. I would love to see short gameplay to see it in action and I'm sure most of EAB users would like to see it too.
Just do not spend too much time on adding new stuff and balancing old ones, make it playable and everything else could be fixed later or used for next projects. I do not know how I could miss Your post. |
23 March 2017, 01:10 | #39 |
Junior Member
Join Date: Sep 2001
Location: No(R)Way
Age: 42
Posts: 3,222
|
Interesting read, and very nice game in progress !! Want to try Landfill
|
23 March 2017, 12:12 | #40 |
Registered User
Join Date: Apr 2012
Location: Cardiff
Posts: 407
|
@Gzegzolka, kriz
Thanks for all your encouragement. Here's a video! [ Show youtube player ] The object is to match items in a chain. At the beginning of the video you'll see Jam + Bread. Over time, new items are added to the chain - Bread + Toaster, Toaster + Electrical Plug, and so on. As new items are added it becomes a quick memory/observation test of what goes with what (I think I have 28 items in total). To make things easier, you can use Fire Button + Direction to swap with the item to the left or right. You can also use this to remove more tiles in one go and create chain reactions which gives you a higher score. You mention getting the gameplay right Gzegzolka - I couldn't agree more! My template for the 'feel' of Landfill is Twintris which I think is a fantastic version of Tetris. So, for example, pulling down on the joystick speeds up the block but you can still control it as it drops. You can also briefly 'slide' off objects to manoeuvre into a space, rather than them sticking like glue. Enough waffling - hope you like it. Last edited by clebin; 23 March 2017 at 20:26. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
GameSmith bookmarked manual | sir_xeno | project.Amiga File Server | 0 | 27 July 2012 10:33 |
My Projects | Amigaman | Hardware mods | 17 | 24 January 2011 18:11 |
Who here uses GameSmith with C or C++ | davideo | Coders. General | 20 | 12 June 2010 15:34 |
Gamesmith | Jherek Carnelia | request.Apps | 7 | 12 March 2008 23:40 |
Proposal: Split Amiga projects and PC projects? | andreas | project.Amiga Game Factory | 4 | 12 February 2008 12:00 |
|
|