cmjn.bas 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. #include "library/msx1filvrm.bas"
  2. #include "library/msx1ldirvm.bas"
  3. #include "library/msxcolor.bas"
  4. #include "library/msxscreen.bas"
  5. #include "library/msx1vpoke.bas"
  6. #include "library/msxpalette.bas"
  7. #include "library/msx1putsprite.bas"
  8. #include "library/msxsnsmat.bas"
  9. #include "library/backgroundandsprites.bas"
  10. #include "library/attributes.bas"
  11. #include "library/_msx16x16sprites.bas"
  12. #include "library/msxrnd.bas"
  13. #include "library/_msxwaitvbl_deprecated.bas" '- <-!!! - replace
  14. '-------------------------------------------------------------------------------
  15. '- including binaries... (check redundancy... :S )
  16. goto bininc01end
  17. spr02:
  18. asm
  19. incbin "library/sprites.bin"
  20. end asm
  21. map01:
  22. asm
  23. incbin "library/map.bin"
  24. end asm
  25. bininc01end:
  26. '-------------------------------------------------------------------------------
  27. '- defining variables
  28. dim eee as uinteger at $E000
  29. dim qq2 as uinteger at $E002
  30. dim xpos as uinteger at $E004
  31. dim ypos as uinteger at $E006
  32. dim cpos as uinteger at $E008
  33. dim eez as uinteger at $E00A
  34. dim xdrc as uinteger at $E00C
  35. dim spq0 as uinteger at $E00E
  36. dim ee0 as uinteger at $E010
  37. dim ee1 as uinteger at $E012
  38. dim ee2 as uinteger at $E014
  39. dim ee3 as uinteger at $E016
  40. dim ee4 as uinteger at $E018
  41. dim oxfriso as uinteger at $E01A
  42. dim oxiso as uinteger at $E01C
  43. dim oyiso as uinteger at $E01E
  44. dim shot as uinteger at $E020
  45. dim oxsh as uinteger at $E022
  46. dim oysh as uinteger at $E024
  47. dim seed as uinteger at $E026
  48. dim oxfriso2 as uinteger at $E028
  49. dim score as uinteger at $E02A
  50. dim hiscore as uinteger at $E02C
  51. dim stamina as uinteger at $E02E
  52. dim level as uinteger at $E030
  53. seed=0:score=0:hiscore=0:level=1
  54. '-------------------------------------------------------------------------------
  55. '- sub routines...
  56. sub zprintdecimal(tpos as uinteger,tval as uinteger):
  57. msx1vpoke(6144+tpos+0,48+int(tval/10000) mod 10)
  58. msx1vpoke(6144+tpos+1,48+int(tval/1000) mod 10)
  59. msx1vpoke(6144+tpos+2,48+int(tval/100) mod 10)
  60. msx1vpoke(6144+tpos+3,48+int(tval/10) mod 10)
  61. msx1vpoke(6144+tpos+4,48+tval mod 10)
  62. end sub
  63. sub zprintdecimal4(tpos as uinteger,tval as uinteger):
  64. msx1vpoke(6144+tpos+0,48+int(tval/1000) mod 10)
  65. msx1vpoke(6144+tpos+1,48+int(tval/100) mod 10)
  66. msx1vpoke(6144+tpos+2,48+int(tval/10) mod 10)
  67. msx1vpoke(6144+tpos+3,48+tval mod 10)
  68. end sub
  69. sub zprintdecimal2(tpos as uinteger,tval as uinteger):
  70. msx1vpoke(6144+tpos+0,48+int(tval/10) mod 10)
  71. msx1vpoke(6144+tpos+1,48+tval mod 10)
  72. end sub
  73. '-------------------------------------------------------------------------------
  74. '- whatever...
  75. msxcolor($6,$F,$1)
  76. msxscreen(2,0,0,0)
  77. msx16x16sprites() '- sets 16x16 sprite size, i have no idea how to do it otherwise?
  78. '-------------------------------------------------------------------------------
  79. '- palette...
  80. if (msxsnsmat(2) band 64)<>0 then '- key "a" pressed on booting for default palette
  81. msxpalettehx($1,$222) '- RGB format (hexcolour 12bit, $0C84 means #CC8844)
  82. msxpalettehx($4,$006)
  83. msxpalettehx($6,$D00)
  84. msxpalettehx($7,$0BE)
  85. msxpalettehx($A,$FD0)
  86. msxpalettehx($C,$0A0)
  87. msxpalettehx($D,$E08)
  88. msxpalettehx($F,$FFF)
  89. end if
  90. '-------------------------------------------------------------------------------
  91. '- filling the vram somehow...
  92. for eee=0 to $17FF step $800
  93. msx1ldirvm(eee,@charset01,1024) '-bitmap from the character set (i think)
  94. msx1filvrm(eee+$2000,$AF,1024) '-$AF= yellow and white in the background
  95. msx1filvrm(eee+1024+$2000,$7A,1024) '-$7A= no idea... :S
  96. msx1ldirvm(eee+$2000+256,@attr01,768) '-attributes from the character set (i think)
  97. next
  98. '-------------------------------------------------------------------------------
  99. '- sprites
  100. msx1ldirvm($3800,@spr02,1024)
  101. msx1ldirvm($3800+1024,@spr02,1024)
  102. '-------------------------------------------------------------------------------
  103. '- main loop
  104. mainloop01:
  105. '- still filling the vram somehow... (background area?)
  106. for ee0=0 to 23
  107. msx1ldirvm((ee0*32)+$1800,@map01+(ee0*64),32)
  108. next
  109. '- title
  110. msx1ldirvm($1800+18*32+3,@text01,@text01end-@text01)
  111. msx1ldirvm($1800+19*32+3,@text02,@text02end-@text02)
  112. msx1ldirvm($1800+21*32+3,@text03,@text03end-@text03)
  113. '- key checking
  114. loopkbd111a:
  115. eee=$FF
  116. for ee1=0 to 8
  117. eee=eee band msxsnsmat(ee1)
  118. next
  119. if eee=$FF then: goto loopkbd111a:end if
  120. eee=127
  121. '-------------------------------------------------------------------------------
  122. '- starting some variables...
  123. xdrc=112
  124. xpos=40:ypos=114:cpos=$7
  125. oxsh=xpos:oysh=ypos:shot=0
  126. eee=0:ee4=999
  127. score=0:stamina=99:level=1
  128. '-------------------------------------------------------------------------------
  129. '- randomizing enemies - defining $E040 to $E04F for that (might change...) - xpos,ypos,xdir,ydir
  130. for ee0=0 to 3
  131. poke $E040+(ee0*4),240
  132. poke $E041+(ee0*4),0
  133. poke $E042+(ee0*4),seed:seed=msxrnd(seed)
  134. poke $E043+(ee0*4),seed:seed=msxrnd(seed)
  135. next
  136. '----
  137. '- game loop
  138. gameloop01:
  139. msxwaitvbldeprecated()
  140. eee=eee+1:ee4=ee4-1
  141. '----
  142. '- moving the ship
  143. if (msxsnsmat(8) band 128)=0 then:xpos=xpos+2:xdrc=xdrc+16:end if '- right
  144. if (msxsnsmat(8) band 16)=0 then:xpos=xpos-2:xdrc=xdrc-16:end if '- left
  145. if (msxsnsmat(8) band 64)=0 then:ypos=ypos+2:xdrc=xdrc+16:end if '- down
  146. if (msxsnsmat(8) band 32)=0 then:ypos=ypos-2:xdrc=xdrc-16:end if '- up
  147. if (msxsnsmat(8) band 1)=0 and shot=0 then:shot=1:end if
  148. '----
  149. '- checking boundaries '- fine tune needed
  150. if xpos<8 then:xpos=8:end if
  151. if ypos<16 then:ypos=16:end if
  152. if xpos>232 then:xpos=232:end if
  153. if ypos>160 then:ypos=160:end if
  154. '----
  155. '- stabilizing ship rotation when not moving, i guess?
  156. if xdrc<112 then: xdrc=xdrc+8: end if
  157. if xdrc>112 then: xdrc=xdrc-8: end if
  158. if xdrc<32 then: xdrc=32: end if
  159. if xdrc>192 then: xdrc=192: end if
  160. '----
  161. '- isometric calculation
  162. oxfriso=(int(ypos/4)+int(xpos/8))
  163. ee1=(int(eee/2)+int(oxfriso/1)) mod 32
  164. ee2=((23-((int(eee/4))mod 24)+int(oxfriso/2)) mod 24)
  165. oxfriso2=(int(ypos*2)+int(xpos*1))
  166. '----
  167. '- ship sprite number
  168. spq0=((16*(eee band 2))+64+(int(xdrc/32)-1)*4)
  169. '----
  170. '- displaying ship
  171. if shot=0 then
  172. msx1putsprite(0,xpos,ypos,spq0,cpos)
  173. msx1putsprite(1,xpos,200,spq0,14)
  174. oxsh=xpos:oysh=ypos
  175. else
  176. msx1putsprite(0,xpos,ypos,(6*4),cpos)
  177. msx1putsprite(1,oxsh,oysh,spq0-64,cpos)
  178. oxsh=oxsh+16:oysh=oysh-8
  179. end if
  180. if oysh<0 or oxsh>256 then:shot=0:oxsh=xpos:oysh=ypos:end if
  181. '----
  182. '- displaying enemies
  183. for ee0=0 to 3
  184. 'msx1putsprite(16+ee0,peek($E040+(ee0*4)),peek($E041+(ee0*4)),(7*4),13)
  185. msx1putsprite(16+ee0,peek($E040+(ee0*4))-oxfriso2,peek($E041+(ee0*4))-int(oxfriso2/2),(7*4),13)
  186. poke $E040+(ee0*4),peek($E040+(ee0*4))+((peek($E042+(ee0*4)))/32)-(128/32)
  187. poke $E041+(ee0*4),peek($E041+(ee0*4))+((peek($E043+(ee0*4)))/32)-(128/32)
  188. next
  189. '----
  190. '- colision: rocket on "enemy"
  191. if shot<>0 then
  192. for ee0=0 to 3
  193. if (abs(((peek($E040+(ee0*4))-oxfriso2) band 255) -oxsh)<16) and (abs( ( (peek($E041+(ee0*4))-int(oxfriso2/2)) band 255)-oysh)<16) then:
  194. seed=msxrnd(seed):poke $E040+(ee0*4),seed
  195. seed=msxrnd(seed):poke $E041+(ee0*4),seed
  196. score=score+1
  197. end if
  198. next
  199. end if
  200. if score>hiscore then
  201. hiscore=score
  202. end if
  203. '----
  204. '- colision: "enemies" on ship
  205. for ee0=0 to 3
  206. if (abs(((peek($E040+(ee0*4))-oxfriso2) band 255) -xpos)<16) and (abs( ( (peek($E041+(ee0*4))-int(oxfriso2/2)) band 255)-ypos)<16) then:
  207. stamina=stamina-1
  208. end if
  209. next
  210. '----
  211. '- randomize enemy motions
  212. seed=msxrnd(seed)
  213. if (seed band 255)<32 then
  214. seed=msxrnd(seed):ee0=seed band 3
  215. poke $E042+(ee0*4),seed:seed=msxrnd(seed)
  216. poke $E043+(ee0*4),seed:seed=msxrnd(seed)
  217. end if
  218. '----
  219. '- update background
  220. for ee0=0 to 23
  221. msx1ldirvm((ee0*32)+$1800,@map01+((ee0+ee2)*64)+ee1,32) '- fine tune needed?
  222. next
  223. '----
  224. '- stages? :D (each minute increment the stage, what a bullshit! :D )
  225. if eee>3000 then
  226. level=level+1
  227. end if
  228. '----
  229. '- score table
  230. msx1ldirvm(6144+23*32+6,@text04,2)
  231. zprintdecimal4(23*32+8,score)
  232. msx1ldirvm(6144+23*32+13,@text04+6,2)
  233. zprintdecimal4(23*32+15,hiscore)
  234. msx1ldirvm(6144+23*32+20,@text04+12,2)
  235. zprintdecimal2(23*32+22,stamina)
  236. msx1ldirvm(6144+23*32+25,@text04+16,2)
  237. zprintdecimal2(23*32+27,level)
  238. if stamina>0 then:
  239. goto gameloop01
  240. end if
  241. hiscore=score
  242. msx1ldirvm(6144+16*32+10,@text05,12)
  243. for ee0=0 to 100
  244. msxwaitvbldeprecated()
  245. next
  246. goto mainloop01
  247. '-------------------------------------------------------------------------------
  248. text01:
  249. asm
  250. defb "CMJN"
  251. end asm
  252. text01end:
  253. text02:
  254. asm
  255. defb "Paulo Silva - jun'14"
  256. end asm
  257. text02end:
  258. text03:
  259. asm
  260. defb "Push any key"
  261. end asm
  262. text03end:
  263. text04:
  264. asm
  265. defb "sc0000hs0000pw99st01"
  266. end asm
  267. text04end:
  268. text05:
  269. asm
  270. defb "Game over..."
  271. end asm
  272. text05end:
  273. '-------------------------------------------------------------------------------