home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
301-325
/
apd323
/
spritegrabber.amos
/
spritegrabber.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1978-02-21
|
8KB
|
348 lines
'-----------------------------
'- Bob Grabber Utility -
'- by Aaron Fothergill -
'-(somewhat changed by DEATH)-
'- (c) Mandarin / Jawx 1990 -
'-----------------------------
'
'Here's a list of the changes I made:
'
' 1. The menu looks better (...that's my opinion)
' and take's up almost the same memory.
' 2. I included a counter which always indicates the total number of sprites.
' 3. I added three extra options: AJUST MOUSE, DEL and EXTRAMEMORY.
' 4. Moving from sprite 1 to sprite 103 goes faster when you press the right
' mouse button.
' 5. I included a small error-handler.
' 6. To quit you have to press both mouse buttons, to avoid mistakes.
' 7. Now you pick up a brush exactly at the edges.
' 8. I chose a more suitable mouse-pointer.
' 9. Especially for people with low memory (or people who enjoy looking at the
' huge amount of memory they have) I made a memory-counter.
'10. Before every label or procedure-call off something I added, I made a
' small 'Rem'-statement, so it's easier for you to understand the strange
' programming I've been doing to your program.
'
'Something that off course hasn't changed, is the author, Aaron Fothergill,
'(you probably) who programmed the tricky parts. I really don't mind if you
'cut out all the REMarks, if you're ever going to use it. (Which I hope you
'will.)
'
Rem :I built in an Error-handler, just in case.
On Error Goto REPAIR_FAULT
FAULT
Y=0
YO=-1
SCH=200
SCW=320
Rem :I made it look a bit nicer, graphically.
Unpack 6 To 1
Rem :A nice pointer
Colour 17,$F
Colour 18,$77F
Colour 19,0
Rem :If you hear a sound, it's more obvious you pressed a button.
SOUND
Gosub GTSCRN
SX=0 : SY=0 : SXO=-1 : XO=-1
Screen To Front 1
STZONES
SNUM=1
SHWSNUM[SNUM]
Do
K=Mouse Key : Z=Mouse Zone
If K=0 Then TICK=0
X=X Screen(X Mouse)
If X/160<>XO
XO=X/160
SHWSPRT[Y,SNUM,X]
End If
If K>0 and Z>0
Play 10,0
On Z Gosub DWN,UP,CUT,GTSCRN,GTSPR,SVSPR,DEL,AJUST,QUIT,EXTRAMEM
SHWSPRT[Y,SNUM,X]
End If
If Y<>YO
YO=Y
DISPBAR[Y]
SHWSPRT[Y,SNUM,X]
End If
If SY<>SYO or SX<>SXO
DISPSCRN[SX,SY]
SXO=SX : SYO=SY
End If
A$=Inkey$
If A$=Chr$(30)
If Y>0
Add Y,-4
Else
If SY>0
Add SY,-4
End If
End If
End If
If A$=Chr$(31)
If Y<SCH-24
Add Y,4
Else
If SY<Max(0,SCY-SCH)
Add SY,4
End If
End If
End If
If A$=Chr$(28)
If SX>0
Add SX,-16
End If
End If
If A$=Chr$(29)
If SX<Max(0,SCX-SCW*REZ)
Add SX,16
End If
End If
Loop
Rem :Now you have to press both mouse buttons at the same time to quit.
Rem :This way you will avoid quitting accidentely.
QUIT:
If Mouse Key=3 Then Boom : End
Return
Rem :The limits of the mouse usualy dont't fit the picture.
Rem :Pressing AJUST will fix this.
AJUST:
SCREN=Screen
Screen 0
Limit Mouse
Screen SCREN
Return
REPAIR_FAULT:
SCREN=Screen
Screen To Front 2
Screen Show 2
Screen 2
Locate 2,1 : Print "Error in program. AMOS error code:";Errn;"."
Locate 2,2 : Print " LEFT=Continue (risk of a software failure) RIGHT=Quit program "
Do
If Mouse Key=1 Then Screen Hide 2 : Screen SCREN : Resume Next
If Mouse Key=2 Then Edit
Loop
Rem :This clears all sprites
DEL:
If K=3
Boom
Erase 1
SNUM=1
SHWSNUM[SNUM]
SHWMEM
Wait 37
End If
Return
Rem :This deletes one sprite
EXTRAMEM:
Close Editor
Close Workbench
Erase 6
SHWMEM
Return
GTSPR:
SNUM=1
F$=""
F$=Fsel$("*.ABK","","Load a Sprite Bank")
If F$<>""
F2$=Right$(F$,4)
If Upper$(F2$)=".ABK"
Erase 1
Load F$
A$="" : A=0 : Repeat : A$=A$+Chr$(Peek(Start(1)-8+A)) : Inc A : Until A=8
If A$<>"Sprites "
F$=""
Else
Screen 0
Get Sprite Palette
Screen 1
End If
Else
F$=""
End If
End If
Return
SVSPR:
F$=Fsel$("","","Save the Sprite Bank As:")
If F$<>""
F2$=Right$(F$,4)
If Upper$(F2$)=".ABK"
Save F$,1
End If
End If
Return
Rem :I replaced X2 and Y2 by X2+1 and Y2+1 to include the edges when grabbing a bob
CUT:
Change Mouse 2
If Fast Free+Chip Free>10000
Bob 1,999,1,1
Update
Update Off
Screen To Front 0
Screen 0
Get Block 1,0,0,SCX,SCY
X2O=-1 : Y2O=-1
While Mouse Key<>0 : Wend : Wait 5
While Mouse Key=0 : Wend : X1=X Screen(X Mouse) : Y1=Y Screen(Y Mouse)
While Mouse Key>0 : X2=X Screen(X Mouse) : Y2=Y Screen(Y Mouse)
If X2O<>X2 or Y2O<>Y2
Gosub SHWBOX : X2O=X2 : Y2O=Y2
End If
Wend
Gosub SHWBOX : Put Block 1,0,0
Get Bob SNUM,Max(0,X1),Max(0,Y1) To Max(0,X2+1),Max(0,Y2+1)
Update On
Screen To Front 1 : Screen 1
Bob Off 1
Update
Del Block 1
SHWMEM
End If
Change Mouse 1
Return
SHWBOX:
Put Block 1,0,0
Ink 1
X3=Min(X1,X2) : X2=Max(X1,X2) : X1=X3
Y3=Min(Y1,Y2) : Y2=Max(Y1,Y2) : Y1=Y3
X2=Max(X1+1,X2) : Y2=Max(Y1+1,Y2)
Gr Writing 3
Box X1,Y1 To X2,Y2
Gr Writing 1
Return
Rem :If you press the right mouse button, the SpriteNUMber will increase or
Rem :decrease by 10 (if possible)
DWN:
If SNUM>1
If K=1
Dec SNUM
Else
SNUM=SNUM-10
If SNUM<1
SNUM=1
End If
End If
SHWSNUM[SNUM]
While Mouse Key<>0 and TICK<1000
Inc TICK
Wend : TICK=Min(TICK,500)
End If
Return
UP:
If SNUM<Length(1)+1
If K=1
Inc SNUM
Else
SNUM=SNUM+10
If SNUM>Length(1)
SNUM=Length(1)+1
End If
End If
SHWSNUM[SNUM]
While Mouse Key<>0 and TICK<1000
Inc TICK
Wend : TICK=Min(TICK,500)
End If
Return
GTSCRN:
F$=Fsel$("","","Pick a Picture !")
If F$<>""
Auto View Off
Screen Close 0
If Upper$(Right$(F$,4))=".ABK"
Load F$,5
Unpack 5 To 0
Erase 5
Else
Load Iff F$,0
End If
A=Screen Base+72
SCX=Deek(A+4)
SCY=Deek(A+6)
REZ=1
If Btst(Deek(A),15)
REZ=2
End If
Screen To Front 1
Auto View On
End If
Return
Procedure DISPBAR[YPOS]
Screen Display 1,,48+YPOS,,40
End Proc
Procedure DISPSCRN[XPOS,YPOS]
Shared SCX,SCY
Screen Display 0,,48-YPOS,,SCY
Screen Offset 0,XPOS,0
End Proc
Procedure SHWSNUM[S]
L$=Mid$(Str$(Length(1)),2)
L$=Right$("00"+L$,3)
S$=Mid$(Str$(S),2)
S$=Right$("00"+S$,3)
Ink 7,0
Text 21,14,L$
Text 69,14,S$
SHWMEM
End Proc
Procedure STZONES
Screen 1
Reserve Zone 10
Set Zone 1,49,4 To 63,18
Set Zone 2,97,4 To 111,18
Set Zone 3,113,4 To 143,18
Set Zone 4,145,4 To 175,18
Set Zone 5,177,4 To 207,18
Set Zone 6,209,4 To 239,18
Set Zone 7,241,4 To 255,18
Set Zone 8,257,4 To 283,18
Set Zone 9,285,4 To 315,18
Set Zone 10,106,21 To 136,35
End Proc
Procedure SHWSPRT[YPOS,N,MX]
Screen 0
If Length(1)>=N
BX=80 : If MX<160
BX=240
End If
BY=YPOS+50+Deek(Sprite Base(N)+8)
If YPOS>100
BY=BY-56-Deek(Sprite Base(N)+2)
End If
Bob 1,BX,BY,N
Update
Else
Bob Off 1
Update
End If
Screen 1
End Proc
Procedure SOUND
Set Envel 1,0 To 8,20
Set Envel 1,1 To 8,4
Set Envel 1,2 To 25,0
Led On
End Proc
Procedure FAULT
Screen Open 2,640,32,4,Hires
Curs Off
Cls 0
Paper 0
Pen 1
Palette 0,$F00,$F77,$FFF
Ink 2,0
Box 8,4 To 632,28
Paint 1,1
Ink 1,0
Flash 2,"(000,20)(500,2)(A00,2)(F00,20)(A00,2)(500,2)"
Screen Hide 2
End Proc
Rem :The SHoW free MEMory counter.
Procedure SHWMEM
MEM$=Str$(Chip Free+Fast Free)-" "
MEM$=String$("0",(8-Len(MEM$)))+MEM$
Text 38,31,MEM$
End Proc