25 August 2013, 11:06 | #1 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
Asm: 4 bitplanes starfield (68020+)
Hello ppl,
After going through the excellent video tutorials of Photon, and reading a couple of threads (on plotting dots and rand) in here, this is what I came up with. Tested that assembles in vasm and asmone. Needs 68020 Left mouse button exits, right mouse button enables color switching of $dff180 so you can see raster timing. |
28 August 2013, 10:57 | #2 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
I like this starfield, nice effect, thanks for sharing.
There seems to be something wrong with the code initialization (register not cleared?) because sometimes I get coloured stars on my A1200 (not grey shades, still the bug looks great, hehe), other times there is a vertical orange bar (roughly 50 pixels wide) from top to bottom of the screen, most of the times it works as intended. Compiled with: vasm star4bp.s -o star4bp -m68020 -Fhunkexe BTW: I remember trying something similar when learning 68k assembler long ago, but the routine was much simpler, didn't look this good (not using several bitplanes). Last edited by modrobert; 28 August 2013 at 12:14. |
28 August 2013, 18:05 | #3 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
Try writing $C40 to BPLCON3, and $11 to BPLCON4. This will set the AGA palette- and color table features to OCS compatible settings.
|
28 August 2013, 20:00 | #4 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Leffmann,
That worked, thanks. I added theese two lines during init (right before the create palette comment). Code:
move.w #$C40,$dff106 move.w #$11,$dff10c |
28 August 2013, 22:01 | #5 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
Thanks for the comments and the fix! (applied)
Here is a new version with double buffering (less stars flickering) Waiting for $2a on $dff006 wasn't very double-buffering friendly so I switched to waiting for vertical blank. Added some ugly text routine (on right mouse button displays raster position when the frame loop reaches it's end). But I am thinking that to have a non-glitch starfield you need tripple-buffering, right? Cause, ok, I am clearing the backbuffer, I am writting to active screen...but I guess I miss the stars with y (screen) pos less than the current raster pos. Cheers, /Alex Last edited by alkis; 29 August 2013 at 15:41. Reason: Apply phx's bss section suggestion |
28 August 2013, 22:49 | #6 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
On a sidenote, sublime editor is quite nice (http://www.sublimetext.com/)
If you go to Tools/Build System/New Build System and edit it to: "cmd": ["vasmm68k_mot","-Fhunkexe","-m68020","$file"] and then save it as vasm. You can ctrl-b to build your source code. Also, if you install the M68ksyntax highlighting, it gets even nicer. |
29 August 2013, 04:41 | #7 |
old bearded fool
Join Date: Jan 2010
Location: Bangkok
Age: 56
Posts: 779
|
Any Amiga version of the sublime editor (can't find the source code either)?
I currently use JanoEditor on the A1200, simple but good (nice with the tab feature, typing 'run jed foo.txt' in a shell just opens a new tab if the editor is already running). Was going for 'vim' first, which is my choice in Linux, but the port just got too bloated, sluggish and anti Amiga somehow. Last edited by modrobert; 29 August 2013 at 04:48. |
29 August 2013, 07:07 | #8 | |
Registered User
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 820
|
Quote:
Basically: wait for VBL - change screenpointers - do your magic on backbuffer |
|
29 August 2013, 08:25 | #9 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
@modrobert
No amiga version of sublime. I should have specified that is for cross-developing, sorry. (I am using it on linux) Also, it’s closed source and quite expensive. Still, the free download is fully functional. @britelite The flow I have is: - Wait for VBL - Change the screenpointers - Start blitter clearing the screen that is NOT showing - Calculate new position of stars and draw them at the screen that IS showing If I (or the emulator) haven’t messed up the timing, I measured the clearing of 320x256x4 with the blitter as needing almost a whole frame (minus 10-20 raster lines). So, if by “do your magic on backbuffer” you mean draw stars in the backbuffer, then I don’t think I have the time for that. (would have to waitblit before drawing any stars too) |
29 August 2013, 10:56 | #10 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,636
|
the number of buffers doesn't necessarily matter.. Heck, you can use single buffer if you stay ahead of the beam at all times ;-)
the static vertical bar is probably due to sprites not being properly reset.. |
29 August 2013, 12:45 | #11 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
A size optimization hint:
Put the screen buffer into a BSS section. This will shrink the size of your executable from 138K to 1.5K. Another possibility, when running under OS2+, would be to use the -databss option. It will remove all zero data from the end of a section. |
29 August 2013, 15:48 | #12 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
@hooverphonique
That would be very difficult to achieve with random y-coordinates from stars :-) @phx thanks, patch applied ;-) I went with the BSS section solution, but I got to 7640 bytes and not to 1.5k with vasm (on linux, if that matters...7056 with asmone, 6932 on vasm's executable if I apply m68k-amigaos-strip on it) |
29 August 2013, 19:56 | #13 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Code:
dcb.b NSTARS*starsize |
|
29 August 2013, 21:36 | #14 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
@phx
Yeap. Went to 1568 bytes :-) vasmm68k_mot -m68020 -Fhunk -o star4db.o star4db.s vlink -bamigahunk -o star4db -s star4db.o ls -l star4db -rwxr-xr-x 1 alex alex 1568 Aug 29 22:34 star4db |
30 August 2013, 08:55 | #15 | |
Registered User
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 820
|
Quote:
(Edit) Drawing everything in the backbuffer is the whole point of double buffering, and it doesn't slow down anything (unless there's something wrong with your code) |
|
30 August 2013, 09:39 | #16 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
The original code (first post), clears star, calculates new position, draws star in new position. All that in a single screen. (could do about 900 stars in one frame on emulated A1200)
The second version, eliminates clearing each individual star (and all the housekeeping needed for that) by clearing the whole screen with the blitter, calculates new position, draws star in new position. (this is an overall gain as it can go up to 1600 stars/frame on emulated A1200) The thing is that I can’t draw stars in the backbuffer on the second version, cause backbuffer is being cleared by the blitter. If I waitblit, I bet it would be an overall loss and I’d be able to do something like 100-200 stars/frame. That’s why I wondered if in order to keep the gain of using the blitter in parallel, you actually need triple buffering. - One screen, blitter clears it - Second screen, draw stars in it - Third screen, display it |
30 August 2013, 11:12 | #17 | ||
Registered User
Join Date: Feb 2010
Location: Espoo / Finland
Posts: 820
|
Quote:
Quote:
|
||
30 August 2013, 13:01 | #18 |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,636
|
|
05 September 2013, 17:12 | #19 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 720
|
Ok, just for completeness shake, here is the same thing with tripple buffering.
At least in my emulated A1200, fixes disappearing stars on the upper half of screen (as it should). That's it. No more starfields, I promise :-) |
05 September 2013, 17:53 | #20 | |
Registered User
Join Date: Jan 2012
Location: USA
Posts: 372
|
Quote:
This trick also works really well when using the CPU to clear a buffer while the blitter is line drawing or area filling in another. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
(Lame) C OS starfield | alkis | Coders. C/C++ | 2 | 11 July 2013 18:46 |
Does anyone know what Starfield called in Alien Breed? | Amiga Forever | Coders. General | 5 | 24 June 2011 01:44 |
Using the Copper to mangle the bitplanes. | Andy_C | Coders. General | 7 | 16 March 2011 12:58 |
'Background' colour when all bitplanes are disabled | TCD | request.UAE Wishlist | 7 | 10 July 2010 12:56 |
Starfield in Blitz Basic - helpful critique sought | Anding | Coders. General | 10 | 13 January 2009 21:46 |
|
|