home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ISV Strong Games
/
ISV_STRONG_GAMES.iso
/
arcade
/
bombs
/
!Bombs
/
Code
/
GetSprs
(
.txt
)
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-03-24
|
15KB
|
680 lines
> <Bombs$Dir>.Code.GetSprs
*** Some help: skip all code to the next REM
base 250<<10,sprarea 128<<10
<sprarea!0=128<<10:sprarea!4=0:sprarea!8=16:sprarea!12=16
13+128:
"OS_SpriteOp",256+10,sprarea,"<Bombs$Dir>.Code.Over13"
H%=init:
H%=sprinit:
getsprites
"OS_File",10,"<Bombs$Dir>.GameSpr",&FFD,,!sprites,!sprites+!eos
"FX 15":
$;" at line ";
getsprites
y%=0
x%=0
"OS_SpriteOp",256+34,sprarea,"pattern",x%*64,y%*64-40
EA%=0:B%=0:C%=64:D%=32:E%=tb+masked:F%=256:G%=0:H%=convertspr:
0,0,C%*4-1,D%*4-1
*** Don't change the dimensions of these sprites!
get_pat("t_empty0",tb+EM)
get_pat("t_empty1",tb+masked+1)
get_pat("t_empty2",tb+masked+2)
get_pat("t_empty3",tb+masked+3)
*** Nor these!
get("t_floor",tb+FL,0,0)
get("t_riveted",tb+RI,0,0)
get("t_dissolver",tb+DI,0,0)
get("t_ice",tb+IC,0,0)
get("t_teleport",tb+TR,0,0)
get("t_spin",tb+SP,0,0)
f%=0
get("t_slot"+
~f%,tb+SL+f%,0,0)
*** You can change these, but make sure that all the frames of
*** an animation are the same size!
*** Align the sprites by the following rules: the last two parameters
*** of the PROCget are the offsets, positive offsets mean right and up.
*** If you specify an offset larger than 128, the sprite is centered,
*** but after that an extra offset is added by subtracting 256. So:
*** 256,-4 means the sprite is centered horizontally, but moved vertically
*** by four pixels down.
*** 256,256+2 means the sprite is fully centered, but after that it's
*** moved up two pixels.
f%=1
get("limb_right"+
f%,f%-1,256,0)
get("limb_left"+
f%,f%+4,256,0)
get("limb_up"+
f%,f%+9,256,0)
get("limb_down"+
f%,f%+14,256,0)
f%=1
get("droid"+
f%,droidspr+f%-1,256,256)
get("switch",switchspr,256+4,256+8)
get("c_3",cb,256,32)
get("c_2",cb+1,256,32)
get("c_1",cb+2,256,32)
get("bomb_small",bb,256,256+3)
get("bomb_medium",bb+1,256,256+4)
get("bomb_large",bb+2,256,256+4)
get("bomb_mine",bb+minei-1,256,256+8)
get("bomb_mine",bb+minei,256,256+8)
get("bomb_mine",bb+minei+1,256,256+8)
get("explosion1",eb,256,256)
get("explosion2",eb+1,256,256)
get("explosion3",eb+2,256,256)
get("explosion4",eb+3,256,256)
get("explosion5",eb+4,256,256)
e%=0
get("#"+
e%,digitb+e%,256,0)
get2("t#"+
e%,digitb+e%+10,0,0)
get2("patt2",pattern2,0,0)
get("time",dispb,3,0)
get("level",dispb+1,3,0)
get("pass",dispb+2,3,0)
get("score",dispb+3,0,0)
get("copyright",dispb+4,0,0)
get("lives",dispb+5,3,0)
get(s$,s%,I%,G%)
getspr(1)
get2(s$,s%,I%,G%)
getspr(0)
getspr(m%)
"OS_SpriteOp",256+40,sprarea,s$
A,A,A,W%,H%
I%>127
I%=-W%/2+I%-256
G%>127
G%=-H%/2+G%-256
F%=I%
3:K%=I%
C%=W%+K%
e)C%=(C%
3)-4*((C%
3)>0):D%=H%:E%=s%
F%<0
F%=128-F%
G%<0
G%=128-G%
"OS_SpriteOp",256+34,sprarea,s$,K%*4
i.A%=0:B%=0:F%=F%
m%<<8:H%=convertspr:
0,0,C%*4-1,D%*4-1
get_pat(s$,n%)
"OS_SpriteOp",256+34,sprarea,s$
o9A%=0:B%=0:C%=64:D%=32:E%=n%:F%=256:G%=0:H%=getsp:
p0A%=0:B%=0:C%=0:D%=tb+masked:H%=dosprite:
q)A%=0:B%=0:C%=1:D%=n%:H%=dosprite:
r>A%=0:B%=0:C%=64:D%=32:E%=n%:F%=256:G%=0:H%=convertspr:
0,0,C%*4-1,D%*4-1
w"pix%=2:xres%=320:bitspercol%=8
numanims=5
droidspr=numanims*4
switchspr=droidspr+5
patternspr=switchspr+1
cb=patternspr+1
bb=cb+3
eb=bb+6
dispb=eb+5
digitb=dispb+8
pattern2=digitb+20
tb=pattern2+1
masked=60
EM=0:FL=1:RI=2
DI=3:IC=4:TR=5
SP=6:SL=7
pulsei=0:minei=4:droidi=7
tb+masked+3>256-64
1,"Too many sprites"
empty=12:sp=13:link=14
opt%=0
P%=base:[OPT opt%
setempty
MOV PC,R7
.init
STMFD (sp)!,{link}
MOV R0,#150
adr (1,tmp)
STR R0,[R1]
MOV R0,#149
STR R0,[R1,#4]
MVN R0,#0
STR R0,[R1,#8]
MOV R0,R1
"SWI "OS_ReadVduVariables"
LDR R0,[R1,#4]
str (0,ss)
str (0,to)
ADD R0,R0,#80*1024
str (0,from)
ldr (0,filemax)
adr (1,file)
ADD R0,R1,R0
str (0,sprites)
LDMFD (sp)!,{PC}^
.sprinit
ldr (0,sprites)
MOV R1,#&400
STR R1,eos
ADD R1,R0,R1
MOV R2,#0
.clears
STR R2,[R0],#4
CMP R0,R1
BNE clears
MOV PC,link
index=6:mask=7:dp=8
scr=9:wd=10:ht=11
[OPT opt%
.dosprite
STMFD (sp)!,{R0-R12,link}
STR R0,xc
STR R1,yc
STRB R2,maskf
STR R3,sprn
LDR R0,sprn
ldr (dp,sprites)
LDR R0,[dp,R0,ASL #2]
CMP R0,#0
BNE kn
SWI "OS_WriteS"
-EQUS "No such sprite":EQUD &D0A:ALIGN
MOV PC,#0
ADD dp,dp,R0
LDRB wd,[dp]
STR wd,sw
LDRB ht,[dp,#1]
STR ht,sh
MOV index,wd
LDR R0,xc
LDRB R1,[dp,#2]
CMP R1,#129
%ADDLT R0,R0,R1,ASL #640
xres%
SUBGE R1,R1,#128
%SUBGE R0,R0,R1,ASL #640
xres%
BIC R0,R0,#15
LDR R1,yc
LDRB R2,[dp,#3]
CMP R2,#129
ADDLT R1,R1,R2,ASL #2
SUBGE R2,R2,#128
SUBGE R1,R1,R2,ASL #2
STR R1,yc
BL calc
SUB scr,scr,#4
STR scr,offset
ldr (1,clipx2)
CMP R0,R1
BGE skipsprite
ldr (1,clipx)
CMP R0,R1
ADDLT R0,R0,#1280*64
'MOV R0,R0,LSR #2
(xres%
STMFD (sp)!,{R0}
LDR R0,yc
ldr (1,clipy2)
CMP R0,R1
LDMGEFD (sp)!,{R0}
BGE skipsprite
ldr (1,clipy)
CMP R0,R1
RSBLT R0,R0,R1
MOV R0,R0,LSR #2
ADD R1,R0,ht
MLALT dp,R0,wd,dp
8SUBLT scr,scr,R0,ASL #5+xres%
640+bitspercol%
8SUBLT scr,scr,R0,ASL #7+xres%
640+bitspercol%
SUBLT ht,ht,R0
CMP ht,#0
LDMLEFD (sp)!,{R0}
BLE skipsprite
ldr (2,clipy2)
CMP R1,R2,LSR #2
RSBGE ht,R0,R2,LSR #2
STR scr,offset
LDMFD (sp)!,{R0}
ldr (2,clipx2)
:MOV R2,R2,LSR #2
(xres%
320)+(4
bitspercol%)
CMP R0,R2,ASL #1
BGT neg
ADD R1,R0,wd
CMP R1,R2
RSBGE index,R0,R2
STR index,si
LDRB R0,maskf
CMP R0,#0
BEQ nmask
B maski
<SUB R0,R0,#1280*64
(2*8
bitspercol%*(640
xres%))
ADD index,R0,wd
ldr (2,clipx)
:MOV R2,R2,LSR #2
(xres%
320)+(4
bitspercol%)
CMP index,R2
BLE skipsprite
SUB R1,R2,R0
ADD scr,scr,R1
ADD dp,dp,R1
SUB index,wd,R1
STR index,si
LDRB R0,maskf
CMP R0,#0
BEQ nmask
.maski
LDRB R0,sw
LDRB R1,sh
MLA mask,R0,R1,dp
BL masking
.skipsprite
LDMFD (sp)!,{R0-R12,PC}^
.nmask
BL nomask
LDMFD (sp)!,{R0-R12,PC}^
.masking
LDR R0,[scr,index]
LDR R1,[mask,index]
R0,R0,R1
LDR R1,[dp,index]
R R0,R0,R1
STR R0,[scr,index]
SUBS index,index,#4
BNE masking
SUBS ht,ht,#1
QS PC,link
ADD dp,dp,wd
ADD mask,mask,wd
LDR R0,offset
SUB R1,R0,scr
,2SUB scr,R0,#bitspercol%
4*xres%
320*160
STR scr,offset
SUB scr,scr,R1
MOV R0,index
LDR index,si
B masking
.nomask
LDR R0,[dp,index]
STR R0,[scr,index]
SUBS index,index,#4
BNE nomask
SUBS ht,ht,#1
QS PC,link
ADD dp,dp,wd
LDR R0,offset
SUB R1,R0,scr
<2SUB scr,R0,#bitspercol%
4*xres%
320*160
STR scr,offset
SUB scr,scr,R1
LDR index,si
B nomask
.convertspr
STMFD (sp)!,{R0-R6}
ldr (6,to)
ADD R6,R6,#80<<10
SUB R6,R6,#320
SUB R6,R6,R1,ASL #8
SUB R6,R6,R1,ASL #6
ADD R0,R6,R0
MOV R4,#0
.convloop
LDRB R1,[R0]
CMP R1,#3
Q R1,#0
CMP R1,#208
Q R1,#3
STRB R1,[R0],#1
ADD R4,R4,#1
CMP R4,R2
BNE convloop
MOV R4,#0
SUB R0,R0,R2
SUB R0,R0,#320
SUBS R3,R3,#1
BNE convloop
LDMFD (sp)!,{R0-R6}
.getsp
[ STMFD (sp)!,{R0-R12,link}
setempty
BIC R0,R0,#15
STR R0,xc
STR R1,yc
MOV wd,R2
S R2,wd,#3
RSB R2,R2,#4
ADDNE wd,wd,R2
MOV ht,R3
STR R4,sprn
STR wd,sw
STR ht,sh
BL calc
SUB scr,scr,#4
STR scr,offset
LDR R0,sprn
ldr (14,sprites)
ADD dp,R14,R0,ASL #2
LDR R0,[dp]
CMP R0,#0
BNE known
.unknown
MOV R0,wd
MOV R1,ht
LDR R2,eos
STR R2,[dp]
MUL R0,R1,R0
TST R5,#1<<8
MOVNE R0,R0,ASL #1
ADD R1,R0,R2
ADD R1,R1,#4
STR R1,eos
.known
ldr (0,sprites)
LDR dp,[dp]
ADD dp,dp,R0
STRB wd,[dp]
STRB ht,[dp,#1]
STRB R5,[dp,#2]
STRB R6,[dp,#3]
LDR R0,yc
ldr (1,clipy2)
CMP R0,R1
BGE skipget
ldr (1,clipy)
CMP R0,R1
RSBLT R0,R0,R1
MOV R0,R0,LSR #2
ADD R1,R0,ht
MLALT dp,R0,wd,dp
8SUBLT scr,scr,R0,ASL #5+xres%
640+bitspercol%
8SUBLT scr,scr,R0,ASL #7+xres%
640+bitspercol%
SUBLT ht,ht,R0
CMP ht,#0
BLE skipget
ldr (2,clipy2)
CMP R1,R2,LSR #2
RSBGE ht,R0,R2,LSR #2
STR scr,offset
LDR R0,xc
ldr (2,clipx2)
CMP R0,R2
BGE skipget
ldr (1,clipx)
CMP R0,R1
ADDLT R0,R0,#1280*64
'MOV R0,R0,LSR #2
(xres%
:CMP R0,R2,LSR #2
(xres%
320)+(4
bitspercol%)
BGT negget
ADD R1,R0,wd
CMP R1,R2
RSBGE index,R0,R2
MOVLT index,wd
STR index,si
TST R5,#1<<8
BNE getmasked
B r_data
.negget
<SUB R0,R0,#1280*64
(2*8
bitspercol%*(640
xres%))
ADD index,wd,R0
ldr (2,clipx)
:MOV R2,R2,LSR #2
(xres%
320)+(4
bitspercol%)
CMP index,R2
BLE skipget
SUB R1,R2,R0
ADD scr,scr,R1
ADD dp,dp,R1
SUB index,wd,R1
STR index,si
TST R5,#1<<8
BNE getmasked
.r_data
LDR R0,[scr,index]
STR R0,[dp,index]
SUBS index,index,#4
BNE r_data
SUBS ht,ht,#1
BEQ skipget
LDR R0,offset
SUB R1,R0,scr
2SUB scr,R0,#bitspercol%
4*xres%
320*160
STR scr,offset
SUB scr,scr,R1
LDR index,si
ADD dp,dp,wd
B r_data
.getmasked
LDRB R0,sw
LDRB R1,sh
MLA mask,R0,R1,dp
.r_mask
LDR R0,[scr,index]
STR R0,[dp,index]
STR R1,[mask,index]
SUBS index,index,#4
BNE r_mask
SUBS ht,ht,#1
BEQ skipget
LDR R0,offset
SUB R1,R0,scr
2SUB scr,R0,#bitspercol%
4*xres%
320*160
STR scr,offset
SUB scr,scr,R1
LDR index,si
ADD dp,dp,wd
ADD mask,mask,wd
B r_mask
.skipget
LDMFD (sp)!,{R0-R12,PC}^
.calc
STMFD (sp)!,{R0-R1,link}
MOV R1,R1,LSR #2
RSB R1,R1,#255
LDR scr,to
8ADD scr,scr,R1,ASL #5+xres%
640+bitspercol%
8ADD scr,scr,R1,ASL #7+xres%
640+bitspercol%
R1,R0,#8*640
xres%*8
bitspercol%-1
SUB R0,R0,R1
:ADD scr,scr,R0,ASR #640/xres%+(bitspercol%
MOV R0,scr
LDMFD (sp)!,{R0-R1,PC}^
.sprn
EQUD 0
EQUD 0
EQUD 0
EQUD 0
.offset
EQUD 0
EQUD 0
EQUD 0
EQUD 0
.corx
EQUD 0
.cory
EQUD 0
.xoff
EQUD 0
.yoff
EQUD 0
EQUD 0
.from
EQUD 0
EQUD 0
.clipx
EQUD 0
.clipx2
EQUD 1280
.clipy
EQUD 0
.clipy2
EQUD 1024
.sprites
EQUD 0
.filemax
EQUD 0
.maskf
EQUB 0
ALIGN
.worksp
res(5)
.file
res(sp%)
sp%=sp%<<2
opt%=0
P%+=sp%:=0
[OPT
#%EQUS
sp%+(sp%-255)*(sp%>255),
sp%-=255
sp%<=0
resb(sp%)
opt%=0
P%+=sp%:=0
[OPT
,%EQUS
sp%+(sp%-255)*(sp%>255),
sp%-=255
sp%<=0
bitspercol%=4
[OPT
MOV R0,R0,LSR #1
[OPT
MOV R1,#0
mask%=2^bitspercol%-1
l%=0
bitspercol%
[OPT
TST R0,#mask%<<l%
ADDEQ R1,R1,#mask%<<l%
ldr(reg,adr)
[OPT
E$LDR reg,[empty,#adr-worksp]
str(reg,adr)
[OPT
J$STR reg,[empty,#adr-worksp]
ldrb(reg,adr)
[OPT
O$LDRB reg,[empty,#adr-worksp]
strb(reg,adr)
[OPT
T$STRB reg,[empty,#adr-worksp]
setempty
num=worksp-(P%+8)
num>&FFFF
(opt%
2,"Bad tileaddress offset"
[OPT
[ ADD empty,PC,#num
\%ADD empty,empty,#num
&FF00
adr(reg,adr):
num=adr-worksp
(opt%
(num)>&FFFF
2,"Bad tileaddress offset"
num>=0
[OPT
ADD reg,empty,#num
ADD reg,reg,#num
&FF00
num=-num
[OPT
SUB reg,empty,#num
SUB reg,reg,#num
&FF00
=(opt%>>1)<<1
mov(reg,num%)
A%=num%
first%,pos%
first%=
num%>=0
pos%=-2
pos%+=2
pos%>31
(num%
3<<pos%)<>0
pos%<32
first%
first%
[OPT opt%
~"MOV reg,#num%
&FF<<pos%
first%=
[OPT opt%
&ADD reg,reg,#num%
&FF<<pos%
pos%+=6
pos%>31
num%=-(num%+1):pos%=-2
pos%+=2
pos%>31
(num%
3<<pos%)<>0
pos%<32
first%
first%
[OPT opt%
"MVN reg,#num%
&FF<<pos%
first%=
[OPT opt%
&SUB reg,reg,#num%
&FF<<pos%
pos%+=6
pos%>31
sc(c$)
4c%=(
"EQNECSCCMIPLVSVCHILSGELTGTLEALNV",c$)-1)/2
%P%!-4=(P%!-4
(&F<<28))
c%<<28
bitspercol%=4
[OPT
MOV R0,R0,LSR #1
[OPT
MOV R1,#0
mask%=2^bitspercol%-1
l%=0
bitspercol%
[OPT
TST R0,#mask%<<l%
ADDEQ R1,R1,#mask%<<l%