pouët.net

128b Palette Starfield by Gaston

;########################################################################
;#----------------------------------------------------------------------#
;#                                                                      #
;# 128-BYTES PALETTE STARFIELD                        (C) 1996 DYNO.    #
;#                                                                      #
;#----------------------------------------------------------------------#
;########################################################################



;#----------------------------------------------------------------------#
;# What is a 128 bytes demo ?                                           #
;#----------------------------------------------------------------------#

I saw one day on the Net a contest launched by Dead Hacker Society.

The aim of this contest was to code a demo in less than 128 bytes.
However, due to the tiny lenght of a 128 bytes program, there are some
rules you can apply when writing a 128 bytes demo :

    -> The 128 bytes only include code + data, and does not include
the header of the program, or relocation table.
    -> You can ask to run the demo in a specific video mode, the
demo itself does not have to change the video mode.
    -> You cannot quit a 128 bytes demo, you have to press reset
(otherwise the program would not be able to do anything else than
changing the video mode, and restoring it at the end of the program).



;#----------------------------------------------------------------------#
;# To run the demo ...                                                  #
;#----------------------------------------------------------------------#

To run this demo you first have to change the video mode to 320x200 or
384x240 with 256 colours. This can be done on a RGB-monitor or
VGA-monitor.

Then, depending on the chosen video mode, just click on 320X200.PRG or
384X240.PRG.



;#----------------------------------------------------------------------#
;# Credits ...                                                          #
;#----------------------------------------------------------------------#

The credits for this 128 bytes demo are :

    Idea and code : DYNO.



;#----------------------------------------------------------------------#
;# Some technical explanations ...                                      #
;#----------------------------------------------------------------------#

This starfield is a palette effect, that is to say you obtain this 
effect by changing the palette each VBL.

First of all, the screen is filled with the same pattern on every line,
randomly left or right shifted. The pattern consist of a degrade from
colour 1 to colour 255 then back from colour 1 to colour 255 :

    +-----+-----+-   -+-----+-----+-----+-----+-
    | 001 | 002 | ... | 254 | 255 | 001 | 002 | ...
    +-----+-----+-   -+-----+-----+-----+-----+-

Then, each star is represented by an index value between 1 and 255.
At each VBL, the colour indexed by this value takes a value corresponding
to the star plane (dark grey for the background plane, white for the
foreground plane), then the index is decremented (by a value depending
on the current plane) to obtain the scrolling effect.

With this technique, when you move only one star in the palette, you
can see one or more stars per line, that is to say a lot on the whole
screen. By managing only 12 stars on a 320x200 screen,
12*(320/256)*200 = 3000 stars are displayed ; By managing 24 stars on
a 640*480 screen, 24*(640/256)*480 = 28800 stars are displayed.



;#----------------------------------------------------------------------#
;# Greetings ...                                                        #
;#----------------------------------------------------------------------#

Mega greetings go to Dead Hacker Society for this marvellous idea of
tiny demos. I do not know if you can do a demo in less than 128 bytes
(Yes you can, mine is exactely 126 bytes long), but in your opinion,
what would be the extreme limit for a demo screen ?

Normal greetings go to you, dear reader !



;#----------------------------------------------------------------------#
;# In conclusion ...                                                    #
;#----------------------------------------------------------------------#

If you have any comment, remark, suggestion (For instance a way to
reduce the length of this demo ...), just contact me ...

28 August 1996, Dyno <dyno@aldabase.com>