Advertisement
Guest User

destiny0001.bas rearranged

a guest
Nov 28th, 2012
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.67 KB | None | 0 0
  1. set smartbranching on
  2. set romsize 16k
  3. set kernel_options no_blank_lines
  4.  
  5. rem Declare constants
  6. const true = 1
  7. const false = 0
  8. const none = 0
  9.  
  10. rem English names for joystick directions
  11. const vk_nokey = 0
  12. const vk_left = 1
  13. const vk_right = 2
  14. const vk_up = 3
  15. const vk_down = 4
  16. const vk_upleft = 5
  17. const vk_upright = 6
  18. const vk_downleft = 7
  19. const vk_downright = 8
  20. const vk_reset = 9
  21. const vk_select = 10
  22.  
  23. rem My 26 standard colors for NTSC
  24. const c_brown = $F2
  25. const c_pink = $3C
  26. const c_skyblue = $98
  27. const c_olive = $E4
  28. const c_lilac = $7A
  29. const c_aqua = $B8
  30. const c_orange = $38
  31. const c_blue = $86
  32. const c_red = $46
  33. const c_purple = $64
  34. const c_lime = $DA
  35. const c_gold = $2E
  36. const c_navy = $84
  37. const c_green = $C6
  38. const c_maroon = $42
  39. const c_yellow = $1E
  40. const c_fuchsia = $58
  41. const c_cyan = $A6
  42. const c_white = $0E
  43. const c_ltgray = $0C
  44. const c_silver = $0A
  45. const c_gray = $08
  46. const c_dkgray = $02
  47. const c_black = $00
  48. const c_tan = $FC
  49. const c_forestgreen = $D2
  50.  
  51. rem Object Types
  52. const o_stairsdown = 1
  53. const o_stairsup = 2
  54. const o_warpring = 3
  55.  
  56. const style_a = 0
  57. const style_b = 1
  58. const style_c = 2
  59. const style_d = 3
  60. const style_e = 4
  61. const style_f = 5
  62. const style_g = 6
  63. const style_h = 7
  64. const style_i = 8
  65. const style_j = 9
  66. const style_k = 10
  67. const style_l = 11
  68. const style_m = 12
  69. const style_n = 13
  70. const style_o = 14
  71.  
  72. const pfbase = $A4
  73.  
  74. rem English names for system variables
  75. dim foreground_color=COLUPF
  76. dim background_color=COLUBK
  77.  
  78. rem Declare variables
  79.  
  80. rem Global variables (can't be reassigned)
  81. dim counter = a
  82. dim boolean_variables = b
  83. dim key = c
  84. dim pressed = d
  85. dim cooldown = e
  86. dim dungeonlvl = f
  87. dim worldx = g
  88. dim worldy = h
  89. dim rclass = i
  90. dim roomtype = j
  91. dim lastkey = k
  92. dim tempvar = l
  93. dim gameseed = m
  94. dim objectcolor = n
  95. dim object_type = o
  96. dim item_seed = p
  97. dim inventory = q
  98.  
  99. dim top = r
  100. dim mid = s
  101. dim bot = t
  102.  
  103. dim dat_ptr = u
  104. dim dat_last = v
  105. dim dat_first = w
  106. dim pf_ptr = x
  107.  
  108. COLUPF = c_white
  109. background_color = c_black
  110.  
  111. seed_game
  112. gameseed = gameseed + 1
  113. if joy0fire then rand = gameseed : item_seed = rand : goto game_create
  114. drawscreen
  115. goto seed_game
  116.  
  117.  
  118. game_create
  119.  
  120. rem Init game vars
  121. worldx = 128
  122. worldy = 128
  123. dungeonlvl = 1
  124. rclass = 1
  125. ballx = 80
  126. bally = 52
  127. ballheight = 4
  128. COLUPF = c_white
  129. background_color = c_black
  130. scorecolor = c_red
  131. CTRLPF = $21
  132.  
  133. gosub draw_room
  134.  
  135. background_color = c_dkgray
  136. gosub change_dungeon_color
  137.  
  138. game_begin_step
  139. counter = counter + 1
  140. if cooldown > 0 then cooldown = cooldown - 1
  141.  
  142. game_step
  143.  
  144. if collision(ball, playfield) then gosub player_collision_event
  145. score = 0
  146. score = score + dungeonlvl
  147.  
  148. gosub get_button
  149.  
  150. gosub move_player
  151.  
  152. if collision(ball, player0) && object_type = o_stairsdown then dungeonlvl = dungeonlvl - 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
  153. if collision(ball, player0) && object_type = o_stairsup then dungeonlvl = dungeonlvl + 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
  154. if collision(ball, player0) && object_type = o_warpring then player0x = 0 : player0y = 0 : inventory = o_warpring : item_seed = rand + item_seed + 23
  155.  
  156.  
  157. if bally > 87 then bally = 12 : worldy = worldy + 1 : gosub draw_room : gosub print_open_up bank4
  158. if bally < 3 then bally = 78 : worldy = worldy - 1 : gosub draw_room : gosub print_open_down bank4
  159. if ballx > 141 then ballx = 25 : worldx = worldx + 1 : gosub draw_room : gosub print_open_left bank4
  160. if ballx < 17 then ballx = 134 : worldx = worldx - 1 : gosub draw_room : gosub print_open_right bank4
  161.  
  162. gosub draw_event
  163.  
  164. game_end_step
  165. goto game_begin_step
  166.  
  167. draw_event
  168. COLUP0 = objectcolor
  169. drawscreen
  170. return thisbank
  171.  
  172. change_dungeon_color
  173. tempvar{1} = dungeonlvl{1}
  174. tempvar{2} = 1
  175. rem Setting bits 2 and 3 to 1 keeps things bright
  176. tempvar{3} = 1
  177. tempvar{4} = gameseed{5}
  178. tempvar{5} = dungeonlvl{0}
  179. tempvar{6} = gameseed{1}
  180. tempvar{7} = dungeonlvl{1}
  181.  
  182. COLUPF = tempvar
  183. return thisbank
  184.  
  185. move_player
  186. if key = vk_upleft then ballx = ballx - 1 : bally = bally - 1 : return thisbank
  187. if key = vk_upright then ballx = ballx + 1 : bally = bally - 1 : return thisbank
  188. if key = vk_downleft then ballx = ballx - 1 : bally = bally + 1 : return thisbank
  189. if key = vk_downright then ballx = ballx + 1 : bally = bally + 1 : return thisbank
  190. if key = vk_left then ballx = ballx - 1 : return thisbank
  191. if key = vk_right then ballx = ballx + 1 : return thisbank
  192. if key = vk_up then bally = bally - 1 : return thisbank
  193. if key = vk_down then bally = bally + 1 : return thisbank
  194. return thisbank
  195.  
  196. player_collision_event
  197. if lastkey = vk_left then ballx = ballx + 1
  198. if lastkey = vk_right then ballx = ballx - 1
  199. if lastkey = vk_up then bally = bally + 1
  200. if lastkey = vk_down then bally = bally - 1
  201.  
  202. if lastkey = vk_upleft then ballx = ballx + 1 : bally = bally + 1
  203. if lastkey = vk_upright then ballx = ballx - 1 : bally = bally + 1
  204. if lastkey = vk_downleft then ballx = ballx + 1 : bally = bally - 1
  205. if lastkey = vk_downright then ballx = ballx - 1 : bally = bally - 1
  206.  
  207. return thisbank
  208.  
  209. get_button
  210. lastkey = key
  211. if cooldown = 0 && joy0fire then pressed = pressed + 1 else pressed = 0
  212.  
  213. if joy0up && joy0left then key = vk_upleft : return thisbank
  214. if joy0up && joy0right then key = vk_upright : return thisbank
  215. if joy0down && joy0left then key = vk_downleft : return thisbank
  216. if joy0down && joy0right then key = vk_downright : return thisbank
  217.  
  218.  
  219. if joy0up then key = vk_up : return thisbank
  220. if joy0down then key = vk_down : return thisbank
  221. if joy0left then key = vk_left : return thisbank
  222. if joy0right then key = vk_right : return thisbank
  223. key = vk_nokey
  224. return thisbank
  225.  
  226. calc_roomtype
  227.  
  228. temp1{0} = worldx{0}
  229. temp1{1} = worldy{6}
  230. temp1{2} = dungeonlvl{0}
  231. temp1{3} = worldx{0}
  232. temp1{4} = worldy{0}
  233. temp1{5} = dungeonlvl{0}
  234. temp1{6} = worldx{0}
  235. temp1{7} = worldy{2}
  236.  
  237. temp1 = temp1 + temp1 + temp1
  238.  
  239. temp2{0} = worldx{0}
  240. temp2{1} = worldy{4}
  241. temp2{2} = dungeonlvl{1}
  242. temp2{3} = temp1{7}
  243. temp2{4} = worldy{1}
  244. temp2{5} = dungeonlvl{1}
  245. temp2{6} = worldx{1}
  246. temp2{7} = temp1{1}
  247.  
  248. temp3 = temp1 + temp1 + temp2
  249.  
  250. temp3{0} = worldx{1}
  251. temp3{1} = temp2{2}
  252. temp3{2} = dungeonlvl{5}
  253. temp3{3} = worldx{2}
  254. temp3{4} = worldy{2}
  255. temp3{5} = dungeonlvl{2}
  256. temp3{6} = temp1{3}
  257. temp3{7} = worldy{7}
  258.  
  259. temp1 = temp1 + temp2 + temp3 + temp1 + gameseed
  260. if temp1 = 0 then temp1 = 255
  261. rand = temp1
  262. roomtype = rand
  263. tempvar = rand + worldx + worldy
  264.  
  265. if counter > 230 then roomtype = rand
  266.  
  267. if worldx = 128 && worldy = 128 && dungeonlvl = 1 then roomtype = 1
  268.  
  269. rclass = roomtype / 4 / 4 : roomtype = roomtype & $0F
  270. if rclass = 15 then rclass = style_a
  271. return thisbank
  272.  
  273. draw_room
  274.  
  275. gosub calc_roomtype
  276. gosub print_style bank4
  277.  
  278. player0x = 0 : player0y = 0
  279. if tempvar < 25 && dungeonlvl < 255 then gosub create_stairsup : return thisbank
  280. if tempvar < 50 && dungeonlvl > 1 then gosub create_stairsdown : return thisbank
  281. z = tempvar + item_seed
  282. if z < 51 then gosub create_warpring : return thisbank
  283. return thisbank
  284.  
  285. create_stairsup
  286. rem player0x = 85
  287. rem player0y = 38
  288. objectcolor = c_white
  289. object_type = o_stairsup
  290. gosub load_stairsup bank4
  291. gosub warp_object
  292. return thisbank
  293.  
  294. create_stairsdown
  295. rem player0x = 69
  296. rem player0y = 54
  297. objectcolor = c_black
  298. object_type = o_stairsdown
  299. gosub load_stairsdown bank4
  300. gosub warp_object
  301. return thisbank
  302.  
  303. create_warpring
  304. rem player0x = 69
  305. rem player0y = 54
  306. object_type = o_warpring
  307. gosub paint_object
  308. gosub load_warpring bank4
  309. gosub warp_object
  310. return thisbank
  311.  
  312. paint_object
  313. objectcolor{1} = object_type{0}
  314. objectcolor{2} = gameseed{1}
  315. rem Setting bits 2 and 3 to 1 keeps things bright
  316. objectcolor{3} = 1
  317. objectcolor{4} = gameseed{0}
  318. objectcolor{5} = object_type{1}
  319. objectcolor{6} = gameseed{0}
  320. objectcolor{7} = object_type{2}
  321. return thisbank
  322.  
  323. warp_object
  324. player0x = (rand&63) + 16
  325. player0y = (rand&63) + 16
  326. drawscreen
  327. if collision(player0, playfield) then goto warp_object
  328. return thisbank
  329.  
  330. bank 2
  331.  
  332. bank 3
  333.  
  334. bank 4
  335.  
  336. print_style
  337. if roomtype = 1 && rclass = 0 then gosub load_castle : return otherbank
  338.  
  339. mid = pat_tbl[rclass]
  340. bot = ((tempvar ^ mid) & %00000101) ^ mid
  341. top = bot / 4 & %00000011
  342. bot = bot & %00000011
  343. mid = mid / 4 / 4
  344. mid = (((tempvar ^ mid) & %00000010) ^ mid) & %00000111
  345.  
  346. mid = mid_tbl[mid]
  347. bot = bot_tbl[bot]
  348. top = top_tbl[top]
  349.  
  350. pf_ptr = 0 : dat_ptr = top : dat_last = top + 11
  351. gosub WRI_PF
  352. pf_ptr = 12 : dat_ptr = mid : dat_last = mid + 19
  353. gosub WRI_PF
  354. pf_ptr = 32 : dat_ptr = bot : dat_last = bot + 11
  355. gosub WRI_PF
  356. return otherbank
  357.  
  358. WRI_PF
  359. for dat_ptr = dat_ptr to dat_last
  360. pfbase[pf_ptr] = room_dat[dat_ptr]
  361. pf_ptr = pf_ptr + 1
  362. next
  363. return thisbank
  364.  
  365. data pat_tbl
  366. %00000000, %00011000, %01001010, %00010010,
  367. %01011010, %01010010, %01000010, %01001000,
  368. %01011000, %00000010, %01010000, %00000010,
  369. %01000000, %00001010, %00010000
  370. end
  371.  
  372. data top_tbl
  373. $24, $3C, $18, $30
  374. end
  375.  
  376. data mid_tbl
  377. $84, $70, $5C, $48, $AC, $98, $D4, $C0
  378. end
  379.  
  380. data bot_tbl
  381. $24, $0C, $18, $00
  382. end
  383.  
  384. data room_dat
  385. %11000000, %00000000, %00000000, %11000000
  386. %11110000, %00000000, %00000000, %11110000
  387. %11111111, %11111111, %11111111, %11111111
  388. %11000000, %00000000, %00000000, %11000000
  389. %11110000, %00000000, %00000000, %11110000
  390. %11111111, %00011111, %00011111, %11111111
  391. %11111111, %11111111, %11111111, %11111111
  392. %11111111, %11111111, %11111111, %11111111
  393. %11111111, %11111111, %11111111, %11111111
  394. %11111111, %00011111, %00011111, %11111111
  395. %11111111, %00011111, %00011111, %11111111
  396. %11111111, %00011111, %00011111, %11111111
  397. %11111111, %11111111, %11111111, %11111111
  398. %11110000, %00000000, %00000000, %11110000
  399. %11000000, %00000000, %00000000, %11000000
  400. %11111111, %00011111, %00011111, %11111111
  401. %11110000, %00000000, %00000000, %11110000
  402. %11000000, %00000000, %00000000, %11000000
  403. %10000000, %00000000, %00000000, %10000000
  404. %10000000, %00000000, %00000000, %10000000
  405. %10000000, %00000000, %00000000, %10000000
  406. %10000000, %00000000, %00000000, %10000000
  407. %10000000, %00000000, %00000000, %10000000
  408. %10000000, %00000000, %00000000, %10000000
  409. %00000000, %00000000, %00000000, %00000000
  410. %00000000, %00000000, %00000000, %00000000
  411. %00000000, %00000000, %00000000, %00000000
  412. %10000000, %00000000, %00000000, %10000000
  413. %11111111, %00011111, %00011111, %11111111
  414. %11110000, %00000000, %00000000, %11110000
  415. %11110000, %00000000, %00000000, %11110000
  416. %11110000, %00000000, %00000000, %11110000
  417. %11111111, %00011111, %00011111, %11111111
  418. %11111111, %00011111, %00011111, %11111111
  419. %00000000, %00000000, %00000000, %00000000
  420. %00000000, %00000000, %00000000, %00000000
  421. %00000000, %00000000, %00000000, %00000000
  422. %11111111, %00011111, %00011111, %11111111
  423. %11111111, %00011111, %00011111, %11111111
  424. %00000000, %00000000, %00000000, %11110000
  425. %00000000, %00000000, %00000000, %11110000
  426. %00000000, %00000000, %00000000, %11110000
  427. %11111111, %00011111, %00011111, %11111111
  428. %11111111, %00011111, %00011111, %11111111
  429. %11110000, %00000000, %00000000, %00000000
  430. %11110000, %00000000, %00000000, %00000000
  431. %11110000, %00000000, %00000000, %00000000
  432. %11111111, %00011111, %00011111, %11111111
  433. %10000000, %00000000, %00000000, %10000000
  434. %00000000, %00000000, %00000000, %10000000
  435. %00000000, %00000000, %00000000, %10000000
  436. %00000000, %00000000, %00000000, %10000000
  437. %10000000, %00000000, %00000000, %10000000
  438. %10000000, %00000000, %00000000, %10000000
  439. %10000000, %00000000, %00000000, %00000000
  440. %10000000, %00000000, %00000000, %00000000
  441. %10000000, %00000000, %00000000, %00000000
  442. %10000000, %00000000, %00000000, %10000000
  443. end
  444.  
  445. print_open_left
  446. pfbase[16]=pfbase[16] & %00000011
  447. pfbase[20]=pfbase[20] & %00000011
  448. pfbase[24]=pfbase[24] & %00000011
  449. return otherbank
  450.  
  451. print_open_right
  452. pfbase[19]=pfbase[19] & %00000011
  453. pfbase[23]=pfbase[23] & %00000011
  454. pfbase[27]=pfbase[27] & %00000011
  455. return otherbank
  456.  
  457. print_open_up
  458. pfbase[1]=pfbase[1] & %00011111 : pfbase[2]=pfbase[2] & %00011111
  459. pfbase[5]=pfbase[5] & %00011111 : pfbase[6]=pfbase[6] & %00011111
  460. pfbase[9]=pfbase[9] & %00011111 : pfbase[10]=pfbase[10] & %00011111
  461. return otherbank
  462.  
  463. print_open_down
  464. pfbase[33]=pfbase[33] & %00011111 : pfbase[34]=pfbase[34] & %00011111
  465. pfbase[37]=pfbase[37] & %00011111 : pfbase[38]=pfbase[38] & %00011111
  466. pfbase[41]=pfbase[41] & %00011111 : pfbase[42]=pfbase[42] & %00011111
  467. return otherbank
  468.  
  469. load_stairsup
  470. player0:
  471. %11111111
  472. %10000001
  473. %11111111
  474. %00100001
  475. %00111111
  476. %00001001
  477. %00001111
  478. %00000000
  479. end
  480. return otherbank
  481.  
  482. load_stairsdown
  483. player0:
  484. %11111111
  485. %10000011
  486. %11111111
  487. %10001111
  488. %11111111
  489. %10111111
  490. %11111111
  491. %11111111
  492. end
  493. return otherbank
  494.  
  495. load_castle
  496. pf_ptr = 0 : dat_ptr = 48 : dat_last = 48 + 11
  497. gosub WRI_PF
  498. pf_ptr = 12 : dat_ptr = 112 : dat_last = 112 + 19
  499. gosub WRI_PF
  500. pf_ptr = 32 : dat_ptr = 0 : dat_last = 0 + 11
  501. gosub WRI_PF
  502. gosub print_open_left bank4
  503. gosub print_open_right bank4
  504. gosub print_open_up bank4
  505. gosub print_open_down bank4
  506. return thisbank
  507.  
  508.  
  509. playfield:
  510. XXXXXXXXXXXXX......XXXXXXXXXXXXX
  511. X..............................X
  512. X..............................X
  513. X........XX.XX.XX.XX.XX........X
  514. ..........XXXXXXXXXXXX..........
  515. .........XXXXX....XXXXX.........
  516. ................................
  517. X..............................X
  518. X..............................X
  519. X..............................X
  520. XXXXXXXXXXXXX......XXXXXXXXXXXXX
  521. end
  522. return otherbank
  523.  
  524. load_warpring
  525. player0:
  526. %00111100
  527. %01000010
  528. %00111100
  529. %01011110
  530. %01101110
  531. %00111100
  532. end
  533. return otherbank
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement