336 lines
12 KiB
Plaintext
336 lines
12 KiB
Plaintext
''***************************************
|
|
''* Shoot Demo *
|
|
''* Author: propfan *
|
|
''* Copyright (c) 2010 propfan *
|
|
''* See end of file for terms of use. *
|
|
''***************************************
|
|
|
|
CON
|
|
x_tiles = 8
|
|
y_tiles = 12
|
|
x_pixels = x_tiles << 4
|
|
y_pixels = y_tiles << 4
|
|
vram_size = ( x_pixels * y_pixels ) >> 2 '2bpp
|
|
|
|
scr_w = x_pixels >> 1
|
|
scr_h = y_pixels >> 1
|
|
|
|
_clkmode = xtal1 + pll16x
|
|
_xinfreq = 5_000_000
|
|
_stack = (vram_size + vram_size + 100) >> 2 'accomodate display memory and stack
|
|
|
|
paramcount = 14
|
|
display_base = $8000 - vram_size
|
|
bitmap_base = display_base - vram_size
|
|
|
|
enemies = 5
|
|
bullets = 5
|
|
|
|
|
|
VAR
|
|
long tv_status '0/1/2 = off/visible/invisible read-only
|
|
long tv_enable '0/? = off/on write-only
|
|
long tv_pins '%ppmmm = pins write-only
|
|
long tv_mode '%ccinp = chroma,interlace,ntsc/pal,swap write-only
|
|
long tv_screen 'pointer to screen (words) write-only
|
|
long tv_colors 'pointer to colors (longs) write-only
|
|
long tv_hc 'horizontal cells write-only
|
|
long tv_vc 'vertical cells write-only
|
|
long tv_hx 'horizontal cell expansion write-only
|
|
long tv_vx 'vertical cell expansion write-only
|
|
long tv_ho 'horizontal offset write-only
|
|
long tv_vo 'vertical offset write-only
|
|
long tv_broadcast 'broadcast frequency (Hz) write-only
|
|
long tv_auralcog 'aural fm cog write-only
|
|
|
|
word screen[x_tiles * y_tiles]
|
|
long colors[64]
|
|
|
|
byte bx[bullets]
|
|
byte by[bullets]
|
|
byte ex[enemies]
|
|
byte ey[enemies]
|
|
byte es[enemies]
|
|
|
|
OBJ
|
|
tv : "tv"
|
|
gr : "graphics"
|
|
mouse : "mouse"
|
|
hss : "yma_hss_hive"
|
|
|
|
PUB main
|
|
initFunc
|
|
repeat
|
|
titleFunc
|
|
gameMain
|
|
|
|
|
|
PRI initFunc | i, dx, dy
|
|
longmove(@tv_status, @tvparams, paramcount)
|
|
tv_screen := @screen
|
|
tv_colors := @colors
|
|
|
|
'init colors
|
|
repeat i from 0 to 64
|
|
colors[i] := $00001010 * (i<<1+4) & $F + $0D060D02
|
|
|
|
'init tile screen
|
|
repeat dx from 0 to tv_hc - 1
|
|
repeat dy from 0 to tv_vc - 1
|
|
screen[dy * tv_hc + dx] := display_base >> 6 + dy + dx * tv_vc + ((dy & $3F) << 10)
|
|
|
|
'start services
|
|
tv.start(@tv_status)
|
|
gr.start
|
|
gr.setup(x_tiles, y_tiles, x_pixels >> 1, y_pixels >> 1, bitmap_base)
|
|
|
|
mouse.start(19, 18)
|
|
hss.start
|
|
|
|
'wait 0.5sec. for stability of video signal
|
|
waitcnt( cnt + clkfreq >> 1 )
|
|
|
|
|
|
PRI titleFunc | i,j
|
|
|
|
hss.mus1
|
|
|
|
repeat while mouse.button(0)
|
|
repeat until mouse.button(0)
|
|
|
|
'exit?
|
|
if mouse.button(1)
|
|
hss.shoot_exit
|
|
|
|
gr.clear
|
|
|
|
dispBg
|
|
|
|
'hintergrundgrafiken im banner zeichnen
|
|
gr.colorwidth(1, 1)
|
|
repeat j from 0 to 5
|
|
gr.vec(j*2, j*5+100-(cnt>>23), 200-j*40, cnt>>16, @vecdef3)
|
|
repeat j from 0 to 5
|
|
gr.vec(j*2, j*5+200-(cnt>>23), 200-j*40, cnt>>16, @vecdef2)
|
|
repeat j from 0 to 5
|
|
gr.vec(j*2, j*5+300-(cnt>>23), 200-j*40, cnt>>16, @vecdef)
|
|
|
|
|
|
gr.colorwidth(2, 4)
|
|
gr.textmode( 3, 3, 6, 5 )
|
|
gr.text( 0, 20, @msg_title )
|
|
|
|
if ( ( cnt >> 26 ) & 1 )
|
|
gr.colorwidth(2, 0)
|
|
gr.textmode( 1, 1, 6, 5 )
|
|
gr.text( 0,-30, @msg_press )
|
|
|
|
gr.copy(display_base)
|
|
|
|
'wait Vsync
|
|
repeat until ( tv_status == 1 )
|
|
|
|
gr.textmode( 1, 1, 6, 0 )
|
|
hss.mus_stop
|
|
|
|
|
|
PRI gameMain | i, j, dx, dy, pp, wt, sync, score, mousex, mousey, gameover
|
|
|
|
' hss.hmus_load(@bgm)
|
|
' hss.hmus_play
|
|
hss.mus2
|
|
|
|
mousex := 0
|
|
mousey := -60
|
|
gameover := 0
|
|
|
|
repeat i from 0 to enemies - 1
|
|
es[i] := 0
|
|
|
|
repeat until gameover
|
|
gr.clear
|
|
|
|
' music monitor
|
|
gr.colorwidth(1, 1)
|
|
repeat i from 0 to 3
|
|
' j := hss.peek(3 + i<<3)
|
|
j := hss.peek(i)
|
|
' gr.plot( j >> 26 - 64, i<<2 + 60 )
|
|
gr.box(i*15-30,20,10,j>>25)
|
|
|
|
'move ship
|
|
mousex := mousex + ( mouse.delta_x / 2 ) #> -scr_w + 5 <# scr_w - 5
|
|
mousey := mousey + ( mouse.delta_y / 2 ) #> -scr_h + 5 <# scr_h >> 1
|
|
gr.plot(mousex - 3, mousey - 3)
|
|
gr.line(mousex, mousey)
|
|
gr.line(mousex + 3, mousey - 3)
|
|
|
|
'shoot bullet
|
|
wt--
|
|
if ( wt < 0 ) AND mouse.button(0)
|
|
wt := 2
|
|
pp := ( pp + 1 ) // bullets
|
|
bx[pp] := mousex + ( ( cnt >> 5 ) & 1 )
|
|
by[pp] := mousey
|
|
' hss.sfx_play(2, @SoundFX1)
|
|
hss.sfx1
|
|
|
|
' enemies
|
|
gr.colorwidth(3, 1)
|
|
repeat i from 0 to enemies - 1
|
|
ey[i]--
|
|
if es[i] == 0
|
|
ex[i] := (-scr_w+15) #> ( ( ( cnt >> 4 ) & 127 ) - 64 ) <# (scr_w-15)
|
|
ey[i] := scr_h
|
|
es[i] := 40 + ( ( cnt >> 5 ) & 127 )
|
|
gr.vec(~ex[i], ~ey[i], es[i], ~ey[i]*( 100 - es[i] ), @vecdef)
|
|
if ~ey[i] < -scr_h
|
|
gameover := 1
|
|
|
|
' bullets
|
|
repeat i from 0 to bullets - 1
|
|
if ~by[i] > scr_h
|
|
next
|
|
by[i] += 12
|
|
gr.colorwidth(1, 2)
|
|
gr.plot(~bx[i], ~by[i] - 8)
|
|
gr.line(~bx[i], ~by[i] + 8)
|
|
repeat j from 0 to enemies - 1
|
|
dx := ||( ~bx[i] - ~ex[j] )
|
|
dy := ||( ~by[i] - ~ey[j] )
|
|
if ( ( dx < es[j]>>2 ) and ( dy < (es[j]>>3 #> 8) ) )
|
|
gr.colorwidth(2,1)
|
|
gr.vec(~bx[i], ~by[i], 90, cnt, @vecdef2)
|
|
es[j] -= es[j] >> 3
|
|
if ( es[j] > 40 )
|
|
gr.colorwidth(2,4)
|
|
gr.vec(~ex[j], ~ey[j], es[j], ~ey[j]*( 100 - es[j] ), @vecdef)
|
|
ey[j] := ( ey[j] + 8 ) <# 127
|
|
else
|
|
es[j] := 0
|
|
score += 1
|
|
' hss.sfx_stop(1)
|
|
' hss.sfx_play(1, @SoundFX2)
|
|
hss.sfx2
|
|
by[i] := 120
|
|
|
|
' show score
|
|
j := score
|
|
repeat i from 3 to 0
|
|
msg[ i ] := ( j // 10 ) + "0"
|
|
j := j / 10
|
|
gr.colorwidth(2, 0)
|
|
gr.text( -scr_w+5, scr_h-15, @msg )
|
|
|
|
'background
|
|
dispBg
|
|
|
|
'copy bitmap to display
|
|
gr.copy(display_base)
|
|
|
|
'wait Vsync
|
|
repeat until ( tv_status == 1 )
|
|
|
|
hss.mus_stop
|
|
waitcnt( cnt + clkfreq )
|
|
|
|
PRI dispBg
|
|
gr.colorwidth(2,1)
|
|
gr.plot(-scr_w, -127)
|
|
gr.line(-scr_w, 127)
|
|
gr.plot(scr_w-1, -127)
|
|
gr.line(scr_w-1, 127)
|
|
|
|
DAT
|
|
'bgm file "yma-mrboss.hmus"
|
|
|
|
|
|
msg byte "0000", 0
|
|
msg_title byte "Shoot", 0
|
|
msg_press byte "Press Button", 0
|
|
|
|
tvparams long 0 'status
|
|
long 1 'enable
|
|
long %010_0101 'pins
|
|
long %0000 'mode
|
|
long 0 'screen
|
|
long 0 'colors
|
|
long x_tiles 'hc
|
|
long y_tiles 'vc
|
|
long 10 'hx
|
|
long 1 'vx
|
|
long 0 'ho
|
|
long 0 'vo
|
|
long 0 'broadcast
|
|
long 0 'auralcog
|
|
|
|
vecdef word $4000+$2000/3*0 'triangle
|
|
word 50
|
|
word $8000+$2000/3*1+1
|
|
word 50
|
|
word $8000+$2000/3*2-1
|
|
word 50
|
|
word $8000+$2000/3*0
|
|
word 50
|
|
word 0
|
|
|
|
vecdef2 word $4000+$2000/12*0 'star
|
|
word 50
|
|
word $8000+$2000/12*1
|
|
word 20
|
|
word $8000+$2000/12*2
|
|
word 50
|
|
word $8000+$2000/12*3
|
|
word 20
|
|
word $8000+$2000/12*4
|
|
word 50
|
|
word $8000+$2000/12*5
|
|
word 20
|
|
word $8000+$2000/12*6
|
|
word 50
|
|
word $8000+$2000/12*7
|
|
word 20
|
|
word $8000+$2000/12*8
|
|
word 50
|
|
word $8000+$2000/12*9
|
|
word 20
|
|
word $8000+$2000/12*10
|
|
word 50
|
|
word $8000+$2000/12*11
|
|
word 20
|
|
word $8000+$2000/12*0
|
|
word 50
|
|
word 0
|
|
|
|
vecdef3 word $4000+$2000/4*0 'box
|
|
word 50
|
|
word $8000+$2000/4*1
|
|
word 30
|
|
word $8000+$2000/4*2
|
|
word 50
|
|
word $8000+$2000/4*3
|
|
word 30
|
|
word $8000+$2000/4*0
|
|
word 50
|
|
word 0
|
|
|
|
|
|
{{
|
|
|
|
┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
|
│ TERMS OF USE: MIT License │
|
|
├──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
|
│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. │
|
|
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
|
}}
|