|
ForumsSega Master System / Mark III / Game GearSG-1000 / SC-3000 / SF-7000 / OMV |
Home - Forums - Games - Scans - Maps - Cheats - Credits Music - Videos - Development - Hacks - Translations - Homebrew |
Author | Message |
---|---|
|
Battleships: My first piece of software
Posted: Thu Aug 11, 2011 5:40 pm Last edited by Killer Bean 2 on Sun Aug 14, 2011 12:38 pm; edited 3 times in total |
A few years ago I read Maxim's programming tutorial and started dreaming about making some sort of software for the Master System. Maxim's tutorial is really great (seriously, it's awesome!), but my understanding of electronics and assembly at the time was lackluster to say the least.
Since then I finished my education as a electronics mechanic, and half a year ago I started an education towards electronics engineering. The basic knowledge I have gained has made me confidente enough to finally start making a somewhat functional game for the Master System. Basically it's just Maxim's tutorial fleshed out to a simple version of the old classic Battleships. But I have to start somewhere :) It's far from finished. But since most of the time I don't have a clue, what I'm doing, I figured I'd let the pros have a look at it before it gets too messy. I'm sure there's a lot of my code (if not all of it) that can be done much more elegantly. If any of you guys will take a quick look at my code and maybe give me some tips and tricks to make it better I'd appreciate it immensely. I know it's a headache to read other people's code, especially when it's bad ;) For instance I'm doing a bit of multiplication/division using loops, and I got a feeling it's better to use shifting? So far the game lets you place your ships, places its own ships and lets you shoot at them. The game also shoots at your ships, but the "AI" is still non-existing :D When the player or the CPU wins, the game just resets. Assembled using WLA DX. ConTEXT project file included. EDIT: I forgot to remove the SMS file. Now it's just the source: EDIT2: New version: |
|
|
Posted: Fri Aug 12, 2011 10:28 pm |
Have to agree with you there, I'm new to the SMS and Maxim's tutorial has helped me a great deal in getting started.
Very nice for a first attempt at something on the SMS. I'm in a similar boat to yourself, and currently working on a simple version of a game (gotta walk before you can run as they say) - though it's still early days yet - only started on it this week - probably have something to show in a week or two.
I haven't looked at your code yet, just assembled and ran the ROM to play a few games. If I feel I can offer any feedback I will, though like you say "the pros" on here are going to be your best source of feedback.
Not looked at the source yet so ....
What you have appeared to be working reasonably well during the few goes I had - so you have a good working prototype to build upon.
Yay I won :)
Assembled and ran fine with my similar setup - no probs :) ---------------------------------------------------------------------------------------------- Keep up the good work, I hope you get some more feedback from other members soon and your project goes on to newer / a final build in the future. Regards Richard |
|
|
Posted: Fri Aug 12, 2011 10:40 pm |
Thanks! :) I'm hoping I can have the game done in time for next year's coding competition. |
|
|
Posted: Sat Aug 13, 2011 9:51 am |
I won!
Its nice, has a nice clean layout has well. In the rules of Battleships are you supposed to know which ship you hit ? I suggest you don't worry too much about the quality and speed of your code. And yours seems reasonnably commented which is a plus :) Your game is only better when the features shows, so try to think in term of how do you want to improve the game and if there's a specific hurdle we can discuss it ihmo. Some suggestions if you want to finish up - Make active cursor animate/blink - Add music using MOD2PSG2 library for a change? - Add messages or a way to distinguish from placement phase to attack phase, it would add a nice touch into the game. Maybe a banner that cover the screen with a drum roll music. That would be a bit challenging to implement! - Add win/lose messages Extra - Animate the successful and failed shots. The key is to find the right balance so that it feels visually nice but not long (nothing worse than being forced to wait for repetitive animations). Otherwise it looks like you are close to completion. I wonder what will be your next game :-) |
|
|
Posted: Sat Aug 13, 2011 3:00 pm |
No, you're right. Total brainfart. I'll have to change that :D
I think you're right. The code isn't timing critical in any way, and the functions are not very hungry for clock cycles. I really don't have to worry about the speed. I'm just an obsessive perfectionist, and I'd hate to get too many bad programming habits to begin with ;) If I hit a wall at some point, I'll put this tread to good use :)
Great suggestions! I think I'll implement most of it. But first I want to make the "AI" a little smarter, and maybe let the player change the difficulty in a menu.
Me too :D Maybe something a little more original. |
|
|
Posted: Sun Aug 14, 2011 12:10 pm |
I have now made a separate placement phase like Bock suggested :)
I have also made the striking anonymous like it should be. |
|
|
Posted: Sun Aug 14, 2011 12:20 pm |
But the striking shouldn't be anonymous on your own side - you should see the ship there :)
About the placement phase, I was about to suggest maybe try to make the whole thing and phrasing more exciting, more thrilling.. But in a way I can appreciate how your game looks like an early "straight-to-the-point" point without bell and whistle. That too has a charm in its own so maybe in this context your placement screen is perfect :) |
|
|
Posted: Sun Aug 14, 2011 12:52 pm |
I know. I need to fix that. Luckily a rewrite of one of my test functions should do the trick :)
I admit, it doesn't do the hardware justice i any way. But I don't want to bite off more than I can chew ;) EDIT: Fixed :D |
|
|
Posted: Thu Aug 18, 2011 1:59 pm |
I've made a "final" version of the game (for now). Basically I'm abandoning the project. The purpose of the whole thing was to explore the fundamentals of SMS programming, and I think it has served it's pursose just fine :)
Now I'll concentrate on small-scale experimentation with scolling, sprite animation, logic tables and stuff like that. Or maybe I'll just make another simple game and try to improve on the fun factor :D |
|
|
Posted: Thu Aug 18, 2011 2:23 pm |
Great! I'll try it shortly.
If that's the final version we'll add it to the Homebrew section as well :) |
|
|
Posted: Thu Aug 18, 2011 3:22 pm |
Cool :) It would be a nice way to "close a chapter". Also great motivation for making better games, since it's crappyness defines my legacy until I do :D |
|
|
Posted: Thu Aug 18, 2011 4:32 pm |
I see this compile warning:
MEM_INSERT: 2. write into $0067 (old: $45, new: $21).
That seems bad... Also, your SDSC versions are a bit funny (all are 1.2). Was that intended? |
|
|
Posted: Thu Aug 18, 2011 5:53 pm |
Lol! Didn't know those were warnings :D Don't know what those warnings mean. Has it something to do with the banking setup?
I built the whole thing with your tutorial as the supporting structure. I never intended for it to be more than just a bit of experimentation and some useless code. I forgot all about the version number. That was just copy/pasted (*blushes*). |
|
|
Posted: Thu Aug 18, 2011 7:20 pm |
I'll take a look, but the MEM_INSERT is almost certainly a problem. It's a warning because it can't tell if you did it on purpose, e.g. patching over some data.
I was going to post the earlier versions too, I may just assign arbitrary version numbers (0.8, 0.9, 1.0) so it makes sense. It might be nice for archaeologists one day to see the changes between versions. |
|
|
Posted: Thu Aug 18, 2011 7:51 pm |
Ah, here we go...
.org $0066
;============================================================== ; Pause button handler ;============================================================== ; Do nothing retn .org $0038 ;============================================================== ; Vblank/Hblank interrupt handler ;============================================================== ... ;============================================================== ; Main program ;============================================================== Main: ... The .org $0038 means "output everything from this point on starting at address $0038". Since you already put the "retn" at $0066, it will write over that. The fix is to reorder it so the NMI handler comes between the vblank handler and Main, so Main is assembled from $0068. There will be a gap between the two interrupt handlers, but it's not a big deal. If you use .sections, this problem becomes almost impossible to have, and there's other benefits too, so I recommend using them in future. I'll shortly add it here: http://www.smspower.org/Homebrew/Battleships-SMS with the fix. |
|
|
Posted: Thu Aug 18, 2011 10:19 pm |
I never thought of testing the pause button, since it wasn't suppose to do anything. But now I see, that it gives you a game breaking bug. Thanks for spotting that! Maxim you rock! :)
I'll try to remember that :)
Awesome! If you want to, you can just change the SDSC version to 1.0 or something like that. And thanks for the feedback/bug hunting! :) EDIT: Fixed a stupid typo... |
|
|
Posted: Thu Aug 25, 2011 2:02 pm |
I know I said, that I wouldn't do any further work on this game. But after playing a little with BMP2Tile, I simply had to make some graphical improvements :)
|
|
|
Posted: Thu Aug 25, 2011 2:16 pm |
Nice update on the visuals Killer - the use of the extra colour makes a world of difference :)
Re: BMP2Tile = godsend what more can I say ! Richard / Sket |
|
|
Posted: Thu Aug 25, 2011 4:12 pm |
I compiled and uploaded here:
http://www.smspower.org/Homebrew/Battleships-SMS ...but I didn't make new screenshots yet. |
|
|
Posted: Mon Nov 28, 2011 2:06 pm Last edited by Killer Bean 2 on Fri Oct 12, 2018 8:31 pm; edited 1 time in total |
I want to be sure I understand how .sections work before I start making my next piece of software :) So, another way of fixing the problem would be to do something like this?: .org $0066 ;============================================================== ; Pause button handler ;============================================================== .section "PauseButtonHandler" force ; Do nothing retn .ends .org $0038 ;============================================================== ; Vblank/Hblank interrupt handler ;============================================================== .section "VBlankInteruptHandler" force ... .ends ;============================================================== ; Main program ;============================================================== .section "Main" free Main: ... .ends And then devide all the rest of my code into other .sections? |
|
|
Posted: Mon Nov 28, 2011 2:38 pm |
I usually try to put the .orgs in order, as it's also the order they'll appear in the output; I think the "free" modifier means it doesn't matter, though (and it is the default if not specified). But yes, that's about it; you also need a .bank specifier so WLA DX knows what relocation may happen. | |
|
Posted: Fri Dec 02, 2011 1:34 pm |
In RetroCopy sometimes the crosses I make when playing against the CPU don't show. They are there, but I can't see them. | |
|
Posted: Mon Dec 05, 2011 9:50 pm |
Only the crosses(misses) and not the hits? Does the the "miss" sound play when you strike? Does the score system still work like it's supposed to?
I never encountered this glitch when i tested it in Meka and on real hardware. I'd like to think that it's RetroCopy that's not as accurate as they claim. But it's more likely that I've made some stupid little mistake in my code :) |
|
|
Posted: Wed Dec 07, 2011 1:39 pm |
Yes, everythings works as it's supposed to - I hear the miss-sound and they "are" there, except I don't see them. I think only the misses, yeah. I can test some more. And like I said, it only happens a few times. Most of the crosses I see. | |
|
Posted: Wed Dec 07, 2011 2:19 pm |
Is RetroCopy running in NTSC mode when this happens? | |
|
Posted: Tue Dec 13, 2011 3:37 pm |
I think I know what's wrong. I have not been taking the VDP delay into account. I guess the VDP writes f¤¤ks up now and then or clashes with the Hblank interrupt. I'd might try to fix it sometime, but it's not very high on my to-do list :) | |