Advertisement
Guest User

destiny0001 with asm

a guest
Nov 29th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.74 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_len = v
  105. dim dat_first = w
  106. dim pf_ptr = x
  107.  
  108. macro WRIPFMAC
  109. asm
  110. ldx {2}
  111. ldy {3}
  112. lda {4}
  113. clc
  114. adc {2}
  115. sta {4}
  116. WRI_LOOP
  117. lda {1},y
  118. sta $A4,x
  119. iny
  120. inx
  121. cpx {4}
  122. bcc WRI_LOOP
  123. end
  124. end
  125.  
  126.  
  127.  
  128.  
  129. COLUPF = c_white
  130. background_color = c_black
  131.  
  132. seed_game
  133. gameseed = gameseed + 1
  134. if joy0fire then rand = gameseed : item_seed = rand : goto game_create
  135. drawscreen
  136. goto seed_game
  137.  
  138.  
  139. game_create
  140.  
  141. rem Init game vars
  142. worldx = 128
  143. worldy = 128
  144. dungeonlvl = 1
  145. rclass = 1
  146. ballx = 80
  147. bally = 52
  148. ballheight = 4
  149. COLUPF = c_white
  150. background_color = c_black
  151. scorecolor = c_red
  152. CTRLPF = $21
  153.  
  154. gosub draw_room
  155.  
  156. background_color = c_dkgray
  157. gosub change_dungeon_color
  158.  
  159. game_begin_step
  160. counter = counter + 1
  161. if cooldown > 0 then cooldown = cooldown - 1
  162.  
  163. game_step
  164.  
  165. if collision(ball, playfield) then gosub player_collision_event
  166. score = 0
  167. score = score + dungeonlvl
  168.  
  169. gosub get_button
  170.  
  171. gosub move_player
  172.  
  173. if collision(ball, player0) && object_type = o_stairsdown then dungeonlvl = dungeonlvl - 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
  174. if collision(ball, player0) && object_type = o_stairsup then dungeonlvl = dungeonlvl + 1 : gosub change_dungeon_color : gosub draw_room : ballx = 96 : bally = 40
  175. if collision(ball, player0) && object_type = o_warpring then player0x = 0 : player0y = 0 : inventory = o_warpring : item_seed = rand + item_seed + 23
  176.  
  177.  
  178. if bally > 87 then bally = 12 : worldy = worldy + 1 : gosub draw_room : gosub print_open_up bank4
  179. if bally < 3 then bally = 78 : worldy = worldy - 1 : gosub draw_room : gosub print_open_down bank4
  180. if ballx > 141 then ballx = 25 : worldx = worldx + 1 : gosub draw_room : gosub print_open_left bank4
  181. if ballx < 17 then ballx = 134 : worldx = worldx - 1 : gosub draw_room : gosub print_open_right bank4
  182.  
  183. gosub draw_event
  184.  
  185. game_end_step
  186. goto game_begin_step
  187.  
  188. draw_event
  189. COLUP0 = objectcolor
  190. drawscreen
  191. return thisbank
  192.  
  193. change_dungeon_color
  194. tempvar{1} = dungeonlvl{1}
  195. tempvar{2} = 1
  196. rem Setting bits 2 and 3 to 1 keeps things bright
  197. tempvar{3} = 1
  198. tempvar{4} = gameseed{5}
  199. tempvar{5} = dungeonlvl{0}
  200. tempvar{6} = gameseed{1}
  201. tempvar{7} = dungeonlvl{1}
  202.  
  203. COLUPF = tempvar
  204. return thisbank
  205.  
  206. move_player
  207. if key = vk_upleft then ballx = ballx - 1 : bally = bally - 1 : return thisbank
  208. if key = vk_upright then ballx = ballx + 1 : bally = bally - 1 : return thisbank
  209. if key = vk_downleft then ballx = ballx - 1 : bally = bally + 1 : return thisbank
  210. if key = vk_downright then ballx = ballx + 1 : bally = bally + 1 : return thisbank
  211. if key = vk_left then ballx = ballx - 1 : return thisbank
  212. if key = vk_right then ballx = ballx + 1 : return thisbank
  213. if key = vk_up then bally = bally - 1 : return thisbank
  214. if key = vk_down then bally = bally + 1 : return thisbank
  215. return thisbank
  216.  
  217. player_collision_event
  218. if lastkey = vk_left then ballx = ballx + 1
  219. if lastkey = vk_right then ballx = ballx - 1
  220. if lastkey = vk_up then bally = bally + 1
  221. if lastkey = vk_down then bally = bally - 1
  222.  
  223. if lastkey = vk_upleft then ballx = ballx + 1 : bally = bally + 1
  224. if lastkey = vk_upright then ballx = ballx - 1 : bally = bally + 1
  225. if lastkey = vk_downleft then ballx = ballx + 1 : bally = bally - 1
  226. if lastkey = vk_downright then ballx = ballx - 1 : bally = bally - 1
  227.  
  228. return thisbank
  229.  
  230. get_button
  231. lastkey = key
  232. if cooldown = 0 && joy0fire then pressed = pressed + 1 else pressed = 0
  233.  
  234. if joy0up && joy0left then key = vk_upleft : return thisbank
  235. if joy0up && joy0right then key = vk_upright : return thisbank
  236. if joy0down && joy0left then key = vk_downleft : return thisbank
  237. if joy0down && joy0right then key = vk_downright : return thisbank
  238.  
  239.  
  240. if joy0up then key = vk_up : return thisbank
  241. if joy0down then key = vk_down : return thisbank
  242. if joy0left then key = vk_left : return thisbank
  243. if joy0right then key = vk_right : return thisbank
  244. key = vk_nokey
  245. return thisbank
  246.  
  247. calc_roomtype
  248.  
  249. temp1{0} = worldx{0}
  250. temp1{1} = worldy{6}
  251. temp1{2} = dungeonlvl{0}
  252. temp1{3} = worldx{0}
  253. temp1{4} = worldy{0}
  254. temp1{5} = dungeonlvl{0}
  255. temp1{6} = worldx{0}
  256. temp1{7} = worldy{2}
  257.  
  258. temp1 = temp1 + temp1 + temp1
  259.  
  260. temp2{0} = worldx{0}
  261. temp2{1} = worldy{4}
  262. temp2{2} = dungeonlvl{1}
  263. temp2{3} = temp1{7}
  264. temp2{4} = worldy{1}
  265. temp2{5} = dungeonlvl{1}
  266. temp2{6} = worldx{1}
  267. temp2{7} = temp1{1}
  268.  
  269. temp3 = temp1 + temp1 + temp2
  270.  
  271. temp3{0} = worldx{1}
  272. temp3{1} = temp2{2}
  273. temp3{2} = dungeonlvl{5}
  274. temp3{3} = worldx{2}
  275. temp3{4} = worldy{2}
  276. temp3{5} = dungeonlvl{2}
  277. temp3{6} = temp1{3}
  278. temp3{7} = worldy{7}
  279.  
  280. temp1 = temp1 + temp2 + temp3 + temp1 + gameseed
  281. if temp1 = 0 then temp1 = 255
  282. rand = temp1
  283. roomtype = rand
  284. tempvar = rand + worldx + worldy
  285.  
  286. if counter > 230 then roomtype = rand
  287.  
  288. if worldx = 128 && worldy = 128 && dungeonlvl = 1 then roomtype = 1
  289.  
  290. rclass = roomtype / 4 / 4 : roomtype = roomtype & $0F
  291. if rclass = 15 then rclass = style_a
  292. return thisbank
  293.  
  294. draw_room
  295.  
  296. gosub calc_roomtype
  297. gosub print_style bank4
  298.  
  299. player0x = 0 : player0y = 0
  300. if tempvar < 25 && dungeonlvl < 255 then gosub create_stairsup : return thisbank
  301. if tempvar < 50 && dungeonlvl > 1 then gosub create_stairsdown : return thisbank
  302. z = tempvar + item_seed
  303. if z < 51 then gosub create_warpring : return thisbank
  304. return thisbank
  305.  
  306. create_stairsup
  307. rem player0x = 85
  308. rem player0y = 38
  309. objectcolor = c_white
  310. object_type = o_stairsup
  311. gosub load_stairsup bank4
  312. gosub warp_object
  313. return thisbank
  314.  
  315. create_stairsdown
  316. rem player0x = 69
  317. rem player0y = 54
  318. objectcolor = c_black
  319. object_type = o_stairsdown
  320. gosub load_stairsdown bank4
  321. gosub warp_object
  322. return thisbank
  323.  
  324. create_warpring
  325. rem player0x = 69
  326. rem player0y = 54
  327. object_type = o_warpring
  328. gosub paint_object
  329. gosub load_warpring bank4
  330. gosub warp_object
  331. return thisbank
  332.  
  333. paint_object
  334. objectcolor{1} = object_type{0}
  335. objectcolor{2} = gameseed{1}
  336. rem Setting bits 2 and 3 to 1 keeps things bright
  337. objectcolor{3} = 1
  338. objectcolor{4} = gameseed{0}
  339. objectcolor{5} = object_type{1}
  340. objectcolor{6} = gameseed{0}
  341. objectcolor{7} = object_type{2}
  342. return thisbank
  343.  
  344. warp_object
  345. player0x = (rand&63) + 16
  346. player0y = (rand&63) + 16
  347. drawscreen
  348. if collision(player0, playfield) then goto warp_object
  349. return thisbank
  350.  
  351. bank 2
  352.  
  353. bank 3
  354.  
  355. bank 4
  356.  
  357. print_style
  358.  
  359. drawscreen
  360.  
  361. if roomtype = 1 && rclass = 0 then gosub load_castle : return otherbank
  362.  
  363. mid = pat_tbl[rclass]
  364. bot = ((tempvar ^ mid) & %00000101) ^ mid
  365. top = bot / 4 & %00000011
  366. bot = bot & %00000011
  367. mid = mid / 4 / 4
  368. mid = (((tempvar ^ mid) & %00000010) ^ mid) & %00000111
  369.  
  370. pf_ptr = 0 : dat_ptr = top_tbl[top] : dat_len = 12
  371. gosub WRI_PF
  372. pf_ptr = 12 : dat_ptr = mid_tbl[mid] : dat_len = 20
  373. gosub WRI_PF
  374. pf_ptr = 32 : dat_ptr = bot_tbl[bot] : dat_len = 12
  375. gosub WRI_PF
  376. return otherbank
  377.  
  378. WRI_PF
  379.  
  380. callmacro WRIPFMAC room_dat pf_ptr dat_ptr dat_len
  381.  
  382. return thisbank
  383.  
  384. data pat_tbl
  385. %00000000, %00011000, %01001010, %00010010,
  386. %01011010, %01010010, %01000010, %01001000,
  387. %01011000, %00000010, %01010000, %00000010,
  388. %01000000, %00001010, %00010000
  389. end
  390.  
  391. data top_tbl
  392. $24, $3C, $18, $30
  393. end
  394.  
  395. data mid_tbl
  396. $84, $70, $5C, $48, $AC, $98, $D4, $C0
  397. end
  398.  
  399. data bot_tbl
  400. $24, $0C, $18, $00
  401. end
  402.  
  403. data room_dat
  404. %11000000, %00000000, %00000000, %11000000
  405. %11110000, %00000000, %00000000, %11110000
  406. %11111111, %11111111, %11111111, %11111111
  407. %11000000, %00000000, %00000000, %11000000
  408. %11110000, %00000000, %00000000, %11110000
  409. %11111111, %00011111, %00011111, %11111111
  410. %11111111, %11111111, %11111111, %11111111
  411. %11111111, %11111111, %11111111, %11111111
  412. %11111111, %11111111, %11111111, %11111111
  413. %11111111, %00011111, %00011111, %11111111
  414. %11111111, %00011111, %00011111, %11111111
  415. %11111111, %00011111, %00011111, %11111111
  416. %11111111, %11111111, %11111111, %11111111
  417. %11110000, %00000000, %00000000, %11110000
  418. %11000000, %00000000, %00000000, %11000000
  419. %11111111, %00011111, %00011111, %11111111
  420. %11110000, %00000000, %00000000, %11110000
  421. %11000000, %00000000, %00000000, %11000000
  422. %10000000, %00000000, %00000000, %10000000
  423. %10000000, %00000000, %00000000, %10000000
  424. %10000000, %00000000, %00000000, %10000000
  425. %10000000, %00000000, %00000000, %10000000
  426. %10000000, %00000000, %00000000, %10000000
  427. %10000000, %00000000, %00000000, %10000000
  428. %00000000, %00000000, %00000000, %00000000
  429. %00000000, %00000000, %00000000, %00000000
  430. %00000000, %00000000, %00000000, %00000000
  431. %10000000, %00000000, %00000000, %10000000
  432. %11111111, %00011111, %00011111, %11111111
  433. %11110000, %00000000, %00000000, %11110000
  434. %11110000, %00000000, %00000000, %11110000
  435. %11110000, %00000000, %00000000, %11110000
  436. %11111111, %00011111, %00011111, %11111111
  437. %11111111, %00011111, %00011111, %11111111
  438. %00000000, %00000000, %00000000, %00000000
  439. %00000000, %00000000, %00000000, %00000000
  440. %00000000, %00000000, %00000000, %00000000
  441. %11111111, %00011111, %00011111, %11111111
  442. %11111111, %00011111, %00011111, %11111111
  443. %00000000, %00000000, %00000000, %11110000
  444. %00000000, %00000000, %00000000, %11110000
  445. %00000000, %00000000, %00000000, %11110000
  446. %11111111, %00011111, %00011111, %11111111
  447. %11111111, %00011111, %00011111, %11111111
  448. %11110000, %00000000, %00000000, %00000000
  449. %11110000, %00000000, %00000000, %00000000
  450. %11110000, %00000000, %00000000, %00000000
  451. %11111111, %00011111, %00011111, %11111111
  452. %10000000, %00000000, %00000000, %10000000
  453. %00000000, %00000000, %00000000, %10000000
  454. %00000000, %00000000, %00000000, %10000000
  455. %00000000, %00000000, %00000000, %10000000
  456. %10000000, %00000000, %00000000, %10000000
  457. %10000000, %00000000, %00000000, %10000000
  458. %10000000, %00000000, %00000000, %00000000
  459. %10000000, %00000000, %00000000, %00000000
  460. %10000000, %00000000, %00000000, %00000000
  461. %10000000, %00000000, %00000000, %10000000
  462. end
  463.  
  464. print_open_left
  465. pfbase[16]=pfbase[16] & %00000011
  466. pfbase[20]=pfbase[20] & %00000011
  467. pfbase[24]=pfbase[24] & %00000011
  468. return otherbank
  469.  
  470. print_open_right
  471. pfbase[19]=pfbase[19] & %00000011
  472. pfbase[23]=pfbase[23] & %00000011
  473. pfbase[27]=pfbase[27] & %00000011
  474. return otherbank
  475.  
  476. print_open_up
  477. pfbase[1]=pfbase[1] & %00011111 : pfbase[2]=pfbase[2] & %00011111
  478. pfbase[5]=pfbase[5] & %00011111 : pfbase[6]=pfbase[6] & %00011111
  479. pfbase[9]=pfbase[9] & %00011111 : pfbase[10]=pfbase[10] & %00011111
  480. return otherbank
  481.  
  482. print_open_down
  483. pfbase[33]=pfbase[33] & %00011111 : pfbase[34]=pfbase[34] & %00011111
  484. pfbase[37]=pfbase[37] & %00011111 : pfbase[38]=pfbase[38] & %00011111
  485. pfbase[41]=pfbase[41] & %00011111 : pfbase[42]=pfbase[42] & %00011111
  486. return otherbank
  487.  
  488. load_stairsup
  489. player0:
  490. %11111111
  491. %10000001
  492. %11111111
  493. %00100001
  494. %00111111
  495. %00001001
  496. %00001111
  497. %00000000
  498. end
  499. return otherbank
  500.  
  501. load_stairsdown
  502. player0:
  503. %11111111
  504. %10000011
  505. %11111111
  506. %10001111
  507. %11111111
  508. %10111111
  509. %11111111
  510. %11111111
  511. end
  512. return otherbank
  513.  
  514. load_castle
  515. pf_ptr = 0 : dat_ptr = 48 : dat_len = 12
  516. gosub WRI_PF
  517. pf_ptr = 12 : dat_ptr = 112 : dat_len = 20
  518. gosub WRI_PF
  519. pf_ptr = 32 : dat_ptr = 0 : dat_len = 12
  520. gosub WRI_PF
  521. gosub print_open_left bank4
  522. gosub print_open_right bank4
  523. gosub print_open_up bank4
  524. gosub print_open_down bank4
  525. return thisbank
  526.  
  527.  
  528. playfield:
  529. XXXXXXXXXXXXX......XXXXXXXXXXXXX
  530. X..............................X
  531. X..............................X
  532. X........XX.XX.XX.XX.XX........X
  533. ..........XXXXXXXXXXXX..........
  534. .........XXXXX....XXXXX.........
  535. ................................
  536. X..............................X
  537. X..............................X
  538. X..............................X
  539. XXXXXXXXXXXXX......XXXXXXXXXXXXX
  540. end
  541. return otherbank
  542.  
  543. load_warpring
  544. player0:
  545. %00111100
  546. %01000010
  547. %00111100
  548. %01011110
  549. %01101110
  550. %00111100
  551. end
  552. return otherbank
  553.  
  554. rem
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement