Advertisement
Guest User

Blackjack

a guest
May 11th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2. #dyn 0x800000
  3.  
  4. #define CARD 0x4020
  5. #define TOTAL 0x4021
  6. #define D 0x4022
  7. #define REG1 0x40F1
  8. #define REG2 0x40F2
  9. #define LASTRESULT 0x800D
  10.  
  11. #org @play
  12. setvar TOTAL 0
  13. call @getcard
  14. call @getcard
  15. :card_loop
  16. msgbox @wantacard
  17. callstd 5
  18. if (LASTRESULT == 0) {
  19. jump :card_loop_end
  20. }
  21. call @getcard
  22. jump :card_loop
  23. :card_loop_end
  24. closemsg
  25. end
  26.  
  27. #org @getcard
  28. call @drawcard
  29. ' TOTAL += CARD
  30. copyvar REG2 TOTAL
  31. copyvar REG1 CARD
  32. call @add
  33. copyvar TOTAL REG2
  34. '
  35. if (TOTAL > 21) {
  36. if (CARD == 11) {
  37. subtractvar TOTAL 10
  38. } else {
  39. jump @lost
  40. }
  41. }
  42. call @echototal
  43. return
  44.  
  45. #org @echototal
  46. storevar 0 TOTAL
  47. msgbox @total
  48. callstd 6
  49. return
  50.  
  51. #org @drawcard
  52. random 12
  53. copyvar CARD LASTRESULT
  54. addvar CARD 1
  55. if (CARD == 1) {
  56. msgbox @as
  57. callstd 6
  58. addvar CARD 10
  59. return
  60. }
  61. if (CARD <= 10) {
  62. storevar 0 CARD
  63. msgbox @num
  64. callstd 6
  65. return
  66. }
  67. if (CARD == 11) {
  68. msgbox @jota
  69. callstd 6
  70. setvar CARD 10
  71. return
  72. }
  73. if (CARD == 12) {
  74. msgbox @reina
  75. callstd 6
  76. setvar CARD 10
  77. return
  78. }
  79. if (CARD == 13) {
  80. msgbox @rei
  81. callstd 6
  82. setvar CARD 10
  83. return
  84. }
  85. msgbox @fail
  86. callstd 6
  87. end
  88.  
  89. #org @lost
  90. storevar 0 TOTAL
  91. msgbox @yalost
  92. callstd 6
  93. end
  94.  
  95. ' Is there a better way to do arithmetic?
  96. ' There has to be...
  97. #org @add
  98. while (REG1 != 0) {
  99. addvar REG2 1
  100. subtractvar REG1 1
  101. }
  102. return
  103.  
  104. #org @sub
  105. while (REG1 != 0) {
  106. subtractvar REG2 1
  107. subtractvar REG1 1
  108. }
  109. return
  110.  
  111. #org @fail
  112. = FATAL ERROR\nCRASH AND BURN!\lFAIL!
  113.  
  114. #org @as
  115. = Un AS!
  116.  
  117. #org @num
  118. = Un \v\h02!
  119.  
  120. #org @jota
  121. = Una jota!
  122.  
  123. #org @reina
  124. = Una reina!
  125.  
  126. #org @rei
  127. = Un rey!
  128.  
  129. #org @total
  130. = Total: \v\h02.
  131.  
  132. #org @wantacard
  133. = Quieres una carta?
  134.  
  135. #org @yalost
  136. = Te has pasado, chico.\nSuman \v\h02.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement