+atari2600land Posted July 16, 2023 Share Posted July 16, 2023 I guess I should have posted about the game here. I had a thread in the Homebrew Games subforum, but I guess many people missed it. So here it is again. Fruit Fly Fun is a game where you swat flies that are trying to eat your banana, and avoid hornets and bees which come after you. I would like to keep this at 2k. I have six bytes left, so not much else can be done unless I would change something I already have. Please play the game and let me know what you think. fly20.bin 1 Quote Link to comment Share on other sites More sharing options...
+Dave C Posted July 16, 2023 Share Posted July 16, 2023 Just tried it, very satisfying to swat the flies. I really like those fly animations and I like seeing a 2K game with lots of color. I really want a way to fight the hornets and bees.. or maybe an enemy like an ant that crawls on the ground... or even a double size fly I have to swat twice.. ...but those 6 bytes in a 2k game... so much easier to go 4k but would be so much cooler to stay 2k... I don't mean to pry but my "scan for ways to get more bytes" OCD is triggered because I just went through one of my own projects that is running into the 4k barrier... way easier than 2k.. The font looks like it might be big. But it's really good looking. But it's big... I see maybe a few places where there *might* be chance for simple code size optimization - things like, if I did a load, I know it sets comparison registers so i can avoid a cmp #0 and get a couple bytes back - but if the changes I want to make need that to be a cmp #1... These jsr sequences differ by one jsr... if you were willing to intermix the two routines you could put the label for F959 at F943 and they'd act the same... 22 bytes isn't a ton but maybe enough to make a double size fly? and then there's... depending on if they aren't called more than once... if you can just inline the code being jsr'ed you save a few bytes + not having to jsr and rts back... Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 16, 2023 Author Share Posted July 16, 2023 Just went through the code and there really isn't much I could do for optimization. I really don't want to break what I have. I did fix a small bug pertaining to the bee's speed. He went a little faster when he was moving right as opposed to left. I think I fixed that. I also fixed the number "8" in the score because I hated the way it looked. 11 bytes free. I removed the obscenities from the code (when I get angry with the way things go, I swear like a drunken sailor) cleaned it up, and posted it here for viewing. fly21.bin fly21.asm Quote Link to comment Share on other sites More sharing options...
glurk Posted July 16, 2023 Share Posted July 16, 2023 There are actually TONS of optimizations possible. I bet I could re-structure and optimize this code and save at least 256 bytes, probably more. But I don't have the spare time to work on it. @Dave C mentioned some of them above. Things like: SoundEffect lda SFXTimer cmp #0 ; this is completely unneeded, LDA affects Z flag beq Silent_Channel_00 New_fly_Angerer_22 lda #10 sta FlyBonusTimerSec lda #10 ; unneeded, ACC already contains #10 from right above sta OverscanValue And so many more. Optimizing 6502 to save every single bit and byte is like a "hobby" of mine, LOL. But you have to know them to implement them. Might be a good topic for a post of it's own really. It would probably serve you well to study some disassembles of other games to see some different approaches / design patterns. Or do a disassembly from scratch. It's a really good way to learn the machine better. I've disassembled about 10 different games, some of them for my 8-bit ports, and I learned more from doing that than I have from anything I've ever read... 2 Quote Link to comment Share on other sites More sharing options...
+Dave C Posted July 16, 2023 Share Posted July 16, 2023 3 hours ago, glurk said: There are actually TONS of optimizations possible. What glurk said - 2k optimization is an art form in and of itself. Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 16, 2023 Author Share Posted July 16, 2023 I got 70 bytes left now. So I tried to put something else in, different colors for the B&W/Color switch, and it didn't like it because the scanline went all over the place. fly23.asm fly23.bin Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 17, 2023 Author Share Posted July 17, 2023 I think I sucessfully added in a double sized fly that needs two hits to kill. fly24.bin Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 17, 2023 Author Share Posted July 17, 2023 Double sized fly appears once player reaches 200+ points. fly25.bin 1 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 18, 2023 Author Share Posted July 18, 2023 Added in black and white colors, but the scanline can either be 261 or 263, not the usual 262. If I change the screen height to 86, it's 263 and if I change it to 85 it's 261. So it can't be 85 1/2. Now it's 263. fly25a.bin 1 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 18, 2023 Author Share Posted July 18, 2023 It's now 262. I'm finished with this unless feedback warrants I work on it some more. fly26.bin Quote Link to comment Share on other sites More sharing options...
+Dave C Posted July 18, 2023 Share Posted July 18, 2023 cool I definitely like the addition. I do have a few more thoughts - just my 2c most important - I think the game should always start with flies (or at least the first game). less important - big flies sooner - maybe every 100? and take lots of hits kind of like fighting a boss, then a speed jump. but that might just be me being bad at the game and having a hard time getting to 200. bonus - if hornet/bee just flies in and tries to keep me from banana - that would actually be a way to be extra aggravating (harder to get to the next flies) Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 18, 2023 Author Share Posted July 18, 2023 minor update: The big flies start at 100 instead of 200. fly27.bin 3 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 19, 2023 Author Share Posted July 19, 2023 I give up. I can't make the scanline count steady at 262. So I guess I'll have to stop working on this. Quote Link to comment Share on other sites More sharing options...
+SvOlli Posted July 20, 2023 Share Posted July 20, 2023 How about releasing the source code for someone else to pick up? There's no guarantee that this will happen, but still there is a good chance... Quote Link to comment Share on other sites More sharing options...
+ZeroPage Homebrew Posted July 20, 2023 Share Posted July 20, 2023 ZeroPage Homebrew is playing Fruit Fly Fun on tomorrow's ZPH stream LIVE on Twitch, hope you can join us! Fri Jul 21, 2023 | LIVE @ 12PM PT | 3PM ET | 7PM GMT WATCH LIVE: https://www.twitch.tv/zeropagehomebrew/WATCH LATER: https://youtube.com/zeropagehomebrew/ Games: Laserface Island (2023 | 2600) by Your Face @Your Face Laserface Planet (2023 WIP | 2600) by Your Face @Your Face Twisty Passages (2006 | 2600) by Fred Quimby @batari Fruit Fly Fun (2023 WIP | 2600) by Chris Read @atari2600land WATCH AT 1080P60 FOR BEST QUALITY 1 Quote Link to comment Share on other sites More sharing options...
Glenn Main Posted July 21, 2023 Share Posted July 21, 2023 2600 programming is hard-easy, hard-easy … I hope you’ll resume here and make a discovery or two! Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 21, 2023 Author Share Posted July 21, 2023 Well, the jumps to 263 only seem to happen for one frame, and they only seem to happen when the fly has been swatted near the banana. I don't know, I'll take another look at it. 1 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted July 21, 2023 Author Share Posted July 21, 2023 I give up. Here is the code for the game. Feel free to ask questions about it if you have any. fly29.asm Quote Link to comment Share on other sites More sharing options...
gambler172 Posted July 21, 2023 Share Posted July 21, 2023 14 hours ago, atari2600land said: I give up. Here is the code for the game. Feel free to ask questions about it if you have any. fly29.asm 29.52 kB · 9 downloads Hi Chris how about a new 7800 game ? 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted July 23, 2023 Share Posted July 23, 2023 On 7/21/2023 at 12:00 AM, atari2600land said: I give up. Here is the code for the game. Feel free to ask questions about it if you have any. fly29.asm 29.52 kB · 16 downloads I wasn't able to reproduce the frame jump when I tried, even when swatting near the banana. Is there a reliable way to reproduce this issue? Quote Link to comment Share on other sites More sharing options...
+ZeroPage Homebrew Posted July 24, 2023 Share Posted July 24, 2023 18 hours ago, Karl G said: I wasn't able to reproduce the frame jump when I tried, even when swatting near the banana. Is there a reliable way to reproduce this issue? I did notice it at least once during my stream of the game. I remember one of them occurred with a big fly on the right hand side of the screen. It happened very seldom so it's possible you may play for quite a while without seeing it. - James EDIT: FOUND THE FRAME JUMP, it's at 1:55:46 and I even mention it during the stream. It just as I remembered, it's when the big fly comes in on the right hand side and takes a bite of the banana. 2 Quote Link to comment Share on other sites More sharing options...
+Dave C Posted July 24, 2023 Share Posted July 24, 2023 7 hours ago, Karl G said: I wasn't able to reproduce the frame jump when I tried, even when swatting near the banana. Is there a reliable way to reproduce this issue? I didn't notice it either. A tip I learned from the forums, Stella (maybe other emulators) lets you set a trap on number of scanlines, makes this kind of thing way easier to debug. Quote Link to comment Share on other sites More sharing options...
+Dave C Posted July 25, 2023 Share Posted July 25, 2023 (edited) On 7/23/2023 at 6:14 PM, ZeroPage Homebrew said: EDIT: FOUND THE FRAME JUMP, it's at 1:55:46 and I even mention it during the stream. It just as I remembered, it's when the big fly comes in on the right hand side and takes a bite of the banana. First off - I can't tell if this whole quitting thing is just normal frustration - which - we all have, or hyperbole, or something darker. If this is something other than just normal coding frustration - honestly take a break. But when it's time to pick things back up.. On fly27.bin, I was able to repro after hacking the score (to speed up the process) There is variable for $82 = OverscanValue that controls a loop that waits through the overscan period. It normally has the value 10, gets written with a value of 15 for just one frame and that causes the wait to take one more scan line (using the timer) I haven't read enough of the code to know what different overscan values compensate for - and counting the cycles is not fun (I do it though...). I also can't repro on fly29.asm. Tbh I'm not sure about the advice I'd give here. As far as I can tell the overscan loop gets hit in exactly the same scan line at the same cycle every frame - correction: the overscan loop appears to be hit on the same scanline every frame +/- a few cycles. If it's always the same scanline the good news would be the overscan doesn't need the variable timer, it can just skip a constant number of lines - which would save on modifying the overscan var and checking the timer. Edited July 25, 2023 by Dave C 4 Quote Link to comment Share on other sites More sharing options...
+Bruce-Robert Pocock Posted July 27, 2023 Share Posted July 27, 2023 On 7/23/2023 at 10:52 PM, Dave C said: I didn't notice it either. A tip I learned from the forums, Stella (maybe other emulators) lets you set a trap on number of scanlines, makes this kind of thing way easier to debug. Just wanna offer up, this is what I use to catch some errors. You can key this in to Stella or put it into a file like ~/Grizzards.NTSC.script (or ~/fly29.script or so) to have it auto-loaded. The first line, stops whenever the frame finishes with less than 262 lines (NTSC) — which can only be detected when the first line of the new frame is produced, but then you can use the "rewind" feature in Stella to walk through the offending frame (or set a breakpoint, or whatever) The second catches overruns when they occur. The third, catches if the stack pointer falls below your top of ZP — so, if you have vars at $80 … $ef you can set it to $f0 like this to catch stack overflows/overwriting actual values. The fourth, I use $f000 as my base address, catches any time that the program jumps into another area of memory, since my code will never do that intentionally. breakIf { _scanEnd < #262 && _scan == 0 && _fCount > 1 } breakIf { _scan > #262 } breakIf { sp < $f0 } breakIf { pc < $f000 } Hope that helps a bit. 3 Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted November 6, 2023 Author Share Posted November 6, 2023 I'm back. I decided to attempt to do this in batari Basic in the hopes that it would help with the scanline issue I was having. I had to get rid of the banana since I have no way of drawing it this way, so I think I'll just call the game Flies! if this goes anywhere. fly1.bin 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.