ScreenSaver v1.0

This commit is contained in:
Tomek Wójcik 2021-01-01 21:56:01 +01:00
parent 53b7ff0f34
commit 137cc90c03
6 changed files with 329 additions and 0 deletions

19
ScreenSaver/LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2020-present BTHLabs <contact@bthlabs.pl> (https://bthlabs.pl)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

52
ScreenSaver/README.md Normal file
View File

@ -0,0 +1,52 @@
# ScreenSaver
This is a "screensaver" program written in AMOS Pro 2.0.
## Description
Years ago (around 2006) I got an extra winter break assignment for my
programming classes - write a DOS graphics mode screensaver in Turbo Pascal.
That code has since been lost, unfortunately.
During Christmas break 2020, I was working on putting my Amiga 1200 back
together and needed a way to put her through her paces to ensure her stability.
I settled for an AMOS Pro 2.0 programming recreating that lost program to the
best of my recollection.
It took me around 8h to write the program on my Amiga. I last touched AMOS
Pro 2.0 over 20o years ago, so I needed some time get used to it again. Also,
programming graphics on Amiga (or any other system for that matter) isn't my
usual glass of beer, so I had to experiment to make things work (kinda) like I
wanted them to. It's not like you can find an answer to _Why the hell double
buffering doesn't work in AMOS?_ on Stack Overflow in 2020 ;). I got it
working, had some fun with it and gave my Miggy a good shakedown.
I tested the program on my machine (AGA, 68030 @ 25MHz, 128MB Fast RAM) and on
emulated bare Amiga 500 (OCS, 68000 @ 7MHz, 0.5MB Chip RAM). It works, so I
declare it done.
## Live Demo
You can see the program running on an emulated Amiga 500
[here](https://www.youtube.com/watch?v=0UcZrYuE1-g).
## Contents of this repository:
* `ScreenSaver.adf` - a bootable ADF that launches the program from the
startup-sequence. Ready for writing to a floppy (or a Gotek flash drive) or
using in an emulator.
* `ScreenSaver.AMOS` - AMOS Pro 2.0 source file.
* `ScreenSaver.AMOS.txt` - TXT printout AMOS Pro 2.0 source file.
## Contributing
If you think you found a bug or want to send a patch, feel free to contact
me through e-mail.
## Author
ScreenSaver is developed by [Tomek Wójcik](https://www.bthlabs.pl/).
## License
ScreenSaver is licensed under the MIT License.

BIN
ScreenSaver/ScreenSaver.AMOS Executable file

Binary file not shown.

258
ScreenSaver/ScreenSaver.AMOS.txt Executable file
View File

@ -0,0 +1,258 @@
' Screen Saver v1.0
' Created By Tomek Wojcik <tomek@bthlabs.pl>
' Copyright 2020-present by BTHLabs (https://bthlabs.pl)
' Licensed under terms of MIT License
' *** Globals
WIDTH=320
HEIGHT=200
PADDING=10
XMIN=PADDING
XMAX=WIDTH-PADDING
YMIN=PADDING
YMAX=HEIGHT-PADDING
PAL_MIN=4
PAL_MAX=15
Global WIDTH,HEIGHT,PADDING,XMIN,YMIN,XMAX,YMAX
' *** Setup
Degree
Auto View Off
Default Palette $0,$FFF,$0,$0,$BA6,$B30,$625,$FC0,$690,$CB6,$373,$F0,$8EE,$AAA,$737,$A26
Screen Open 0,WIDTH,HEIGHT,16,Lowres : Screen Show 0
Screen Open 1,WIDTH,HEIGHT,16,Lowres : Screen Hide 1
Screen Open 2,WIDTH,HEIGHT,16,Lowres : Screen Hide 2
Hide : Flash Off
Screen 0 : Curs Off
Screen 1 : Curs Off
Screen 2 : Curs Off
' *** Main Stuff
Procedure MAIN_DRAW_BORDER
Cls 0
Ink 1,0
Box 4,4 To 316,196
Pen 1 : Paper 0
Locate 0,0
Centre "Screen Saver"
Locate 0,24
Centre "By BTHLabs. For teh lulz."
Locate 35,0 : Pen 13 : Paper 0
Print "v1.0";
End Proc
Screen 0
MAIN_DRAW_BORDER
View
' *** The Rect Module
RECT_PEN_MIN=4
RECT_PEN_MAX=15
RECT_MIN_SIZE=8
Global RECT_PEN_MIN,RECT_PEN_MAX,RECT_MIN_SIZE
Procedure RECT_TICK
If Timer mod 3=0
Randomize Timer
RECT_PEN=RECT_PEN_MIN+Rnd(RECT_PEN_MAX-RECT_PEN_MIN)
RECT_WIDTH=RECT_MIN_SIZE+Rnd(XMAX-PADDING-RECT_MIN_SIZE)
RECT_HEIGHT=RECT_MIN_SIZE+Rnd(YMAX-PADDING-RECT_MIN_SIZE)
If RECT_WIDTH=XMAX-PADDING
RECT_X=0
Else
RECT_X=Rnd(XMAX-PADDING-RECT_WIDTH)
End If
If RECT_HEIGHT=YMAX-PADDING
RECT_Y=0
Else
RECT_Y=Rnd(YMAX-PADDING-RECT_HEIGHT)
End If
Ink RECT_PEN,RECT_PEN
RECT_FX=XMIN+RECT_X
RECT_FY=YMIN+RECT_Y
RECT_TX=RECT_FX+RECT_WIDTH
RECT_TY=RECT_FY+RECT_HEIGHT
Bar RECT_FX,RECT_FY To RECT_TX,RECT_TY
End If
End Proc
' *** The Radar Module
RADAR_CX=WIDTH/2
RADAR_CY=HEIGHT/2
RADAR_RADIUS=64
RADAR_STEP=0
RADAR_MAX_STEP=35
Dim RADAR_POINTS(36,2)
Global RADAR_CX,RADAR_CY,RADAR_RADIUS,RADAR_STEP,RADAR_MAX_STEP,RADAR_POINTS()
Procedure RADAR_INIT
MAIN_DRAW_BORDER
RADAR_STEP=0
For I=0 To RADAR_MAX_STEP
RADAR_POINTS(I,0)=0
RADAR_POINTS(I,1)=0
Next I
Ink 1,0
Circle RADAR_CX,RADAR_CY,RADAR_RADIUS
Ink 10,0
Paint RADAR_CX,RADAR_CY
Ink 1,0
Circle RADAR_CX,RADAR_CY,1
Ink 11,0
Circle RADAR_CX,RADAR_CY,48
Circle RADAR_CX,RADAR_CY,32
Circle RADAR_CX,RADAR_CY,16
End Proc
Procedure RADAR_TICK
Screen Copy 2 To 1
Randomize Timer
RADAR_ANGLE=10*RADAR_STEP
RADAR_POINT_DIST=8+Rnd(RADAR_RADIUS-10)
RADAR_POINT_X=RADAR_POINT_DIST*Cos(RADAR_ANGLE)
RADAR_POINT_Y=RADAR_POINT_DIST*Sin(RADAR_ANGLE)
RADAR_POINTS(RADAR_STEP,0)=RADAR_POINT_X
RADAR_POINTS(RADAR_STEP,1)=RADAR_POINT_Y
Ink 7,0
For I=0 To RADAR_MAX_STEP
If RADAR_POINTS(I,0)<>0 and RADAR_POINTS(I,1)<>0
Plot RADAR_CX-RADAR_POINTS(I,0),RADAR_CY-RADAR_POINTS(I,1)
End If
Next I
If RADAR_STEP=RADAR_MAX_STEP
RADAR_STEP=0
Else
RADAR_STEP=RADAR_STEP+1
End If
RADAR_ANGLE=10*RADAR_STEP
RADAR_HAND_X=(RADAR_RADIUS)*Cos(RADAR_ANGLE)
RADAR_HAND_Y=(RADAR_RADIUS)*Sin(RADAR_ANGLE)
Ink 1,0
Draw RADAR_CX,RADAR_CY To RADAR_CX-RADAR_HAND_X,RADAR_CY-RADAR_HAND_Y
End Proc
' *** The Text Module
TXT_PEN_BASE=13
TXT_PEN_SPECIAL=1
Dim TXT_SPECIAL_STRINGS$(3)
TXT_SPECIAL_STRINGS$(0)="Basia"
TXT_SPECIAL_STRINGS$(1)="Ziomek"
TXT_SPECIAL_STRINGS$(2)="Tomek"
Dim TXT_SPECIAL_STRING_COORDS(3,2)
Global TXT_PEN_BASE,TXT_PEN_SPECIAL,TXT_SPECIAL_STRINGS$(),TXT_SPECIAL_STRING_COORDS()
Procedure TXT_INIT
Randomize Timer
For Y=1 To 23
For X=1 To 38
Pen TXT_PEN_BASE
Locate X,Y : Print Chr$(32+Rnd(64));
Next X
Next Y
For I=0 To 2
TXT_SPECIAL_STRING$=TXT_SPECIAL_STRINGS$(I)
TXT_SPECIAL_STRING_COORDS(I,0)=1+Rnd(37-Len(TXT_SPECIAL_STRING$))
TXT_SPECIAL_STRING_COORDS(I,1)=1+Rnd(23)
Next I
End Proc
Procedure TXT_TICK
Randomize Timer
TXT_HIGHLIGHT_COUNT=Rnd(50)
For I=0 To TXT_HIGHLIGHT_COUNT
TXT_HIGHLIGHT_X=1+Rnd(37)
TXT_HIGHLIGHT_Y=1+Rnd(22)
TXT_HIGHLIGHT_PEN=4+Rnd(11)
Locate TXT_HIGHLIGHT_X,TXT_HIGHLIGHT_Y
Pen TXT_HIGHLIGHT_PEN : Paper 0
Print Chr$(32+Rnd(64));
Next I
For I=0 To 2
Pen TXT_PEN_SPECIAL : Paper 0
Locate TXT_SPECIAL_STRING_COORDS(I,0),TXT_SPECIAL_STRING_COORDS(I,1)
Print TXT_SPECIAL_STRINGS$(I);
Next I
End Proc
' *** The Main Loop
CURRENT_MOD=0
CURRENT_MOD_MAX_TIME=250
LOCK_CURRENT_MOD=False
Global CURRENT_MOD
Procedure CURRENT_MOD_INIT
Screen 2
MAIN_DRAW_BORDER
If CURRENT_MOD=1
RADAR_INIT
Else If CURRENT_MOD=2
TXT_INIT
End If
Screen Copy 2 To 1
End Proc
CURRENT_MOD_INIT
CURRENT_MOD_START=Timer
Do
CURRENT_MOD_TIME=Timer-CURRENT_MOD_START
If LOCK_CURRENT_MOD=False and CURRENT_MOD_TIME>=CURRENT_MOD_MAX_TIME
CURRENT_MOD=CURRENT_MOD+1
If CURRENT_MOD>2
CURRENT_MOD=0
End If
CURRENT_MOD_START=Timer
CURRENT_MOD_INIT
End If
Screen 1
If CURRENT_MOD=0
RECT_TICK
Else If CURRENT_MOD=1
RADAR_TICK
Else If CURRENT_MOD=2
TXT_TICK
End If
Screen Copy 1 To 0
View
Wait Vbl
If Mouse Click<>0 or Key State(69)=True
Exit
End If
Loop

BIN
ScreenSaver/ScreenSaver.adf Executable file

Binary file not shown.

BIN
ScreenSaver/ScreenSaver.exe Executable file

Binary file not shown.