Advertisement
Guest User

Untitled

a guest
Aug 8th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     PROCESSOR 6502
  2.    
  3.     ORG $c000
  4.    
  5. temp1   EQU $fc
  6. temp2   EQU $fd
  7. a       EQU $fe
  8. b       EQU $61
  9. tmpi    EQU $63
  10. s       EQU $65
  11. sm      EQU $67
  12. fi      EQU $69
  13.  
  14.     ; init vars
  15.     lda #$00
  16.     sta s
  17.     sta sm
  18.    
  19.     ; bg color
  20.     lda $d021
  21.     sta $d020
  22.    
  23.     ; clear the screen
  24.    
  25.     lda #$a0
  26.     ldx #$00
  27. loop:
  28.     sta $0400,x
  29.     sta $0500,x
  30.     sta $0600,x
  31.     sta $06e8,x
  32.     inx
  33.     bne loop
  34.    
  35.     ; seed randomizer
  36.    
  37.     lda $a1
  38.     sta random
  39.     lda $a2
  40.     sta random+1
  41.  
  42.     ; initialize a
  43.    
  44.     lda <#1500
  45.     sta a
  46.     lda >#1500
  47.     sta a+1
  48.    
  49.     ; poke a,4
  50.     lda #$04
  51.     ldy #$00
  52.     sta (a),y
  53.    
  54. line_110
  55.     ; j=rnd*4
  56.     jsr RND
  57.     lda random
  58.     and #%00000011
  59.     sta j
  60.     sta x
  61.    
  62.     ; if s>sm then sm=s
  63.     lda s
  64.     cmp sm
  65.     beq line_120
  66.     bmi then2  
  67.     jmp line_120   
  68. then2  
  69.     lda s
  70.     sta sm
  71.  
  72.     ; fi=b
  73.     lda b
  74.     sta fi
  75.     lda b+1
  76.     sta fi+1
  77.    
  78. line_120
  79.  
  80.     ; b = a+a(j)
  81.    
  82.     lda a
  83.     sta b
  84.     lda a+1
  85.     sta b+1
  86.     ldx j
  87.     lda aarr,x
  88.     bmi sub
  89.     clc
  90.     adc b
  91.     sta b
  92.     bcc skip
  93.     inc b+1
  94.     jmp skip
  95. sub
  96.     eor #$ff
  97.     sta temp1
  98.     sec
  99.     lda b
  100.     sbc temp1
  101.     sta b
  102.     bcs skip
  103.     dec b+1
  104. skip
  105.    
  106.     ; if peek(b) = 160
  107.    
  108.     ldy #$00
  109.     lda (b),y
  110.     cmp #160
  111.     beq then
  112.     jmp line_130
  113. then
  114.    
  115.     ; poke b,j
  116.    
  117.     lda j
  118.     sta (b),y
  119.    
  120.     ; poke a+a(j)/2,32
  121.    
  122.     lda a
  123.     sta tmpi
  124.     lda a+1
  125.     sta tmpi+1
  126.    
  127.     ldx j
  128.     lda aarr,x
  129.     bmi negative
  130.     lsr
  131.     clc
  132.     adc tmpi
  133.     sta tmpi
  134.     bcc skip2
  135.     inc tmpi+1
  136. skip2
  137.     jmp now_poke
  138. negative
  139.     eor #$ff
  140.     lsr
  141.     sta temp1
  142.     lda tmpi
  143.     sec
  144.     sbc temp1
  145.     sta tmpi
  146.     bcs now_poke
  147.     dec tmpi+1
  148.  
  149. now_poke   
  150.  
  151.     lda #32
  152.     ldy #0
  153.     sta (tmpi),y
  154.  
  155.     ; a=b:s=s+1
  156.    
  157.     lda b
  158.     sta a
  159.     lda b+1
  160.     sta a+1
  161.     inc s
  162.    
  163.     ; goto 110
  164.    
  165.     jmp line_110
  166.    
  167. line_130
  168.  
  169.     ; j=j+1 and 3
  170.    
  171.     inc j
  172.     lda #3
  173.     and j
  174.     sta j
  175.    
  176.     ; if j<>x then 120
  177.    
  178.     cmp x
  179.     beq line_140
  180.     jmp line_120
  181. line_140
  182.  
  183.     ; j = peek(a)
  184.    
  185.     ldy #$00
  186.     lda (a),y
  187.     sta j
  188.    
  189.     ; poke a,32
  190.    
  191.     lda #32
  192.     sta (a),y
  193.    
  194.     ; s=s-1
  195.    
  196.     dec s
  197.    
  198.     ; if j<4
  199.  
  200.     lda j
  201.     cmp #4
  202.     bcc then3
  203.     jmp line_150   
  204.  
  205. then3
  206.  
  207.     ; then a=a-a(j)
  208.  
  209.     ldx j
  210.     lda aarr,x
  211.     bmi neg
  212.     sta temp1
  213.     lda a
  214.     sec
  215.     sbc temp1
  216.     sta a
  217.     bcs skip3
  218.     dec a+1
  219. skip3
  220.     jmp line_110
  221. neg
  222.     eor #$ff
  223.     sta temp1
  224.     lda a
  225.     clc
  226.     adc temp1
  227.     sta a
  228.     bcc skip6
  229.     inc a+1
  230. skip6
  231.  
  232.     ; goto 110
  233.    
  234.     jmp line_110
  235.    
  236. line_150            
  237.  
  238.     ; poke a,1:poke fi,2
  239.     ldy #$00
  240.     lda #1
  241.     sta (a),y
  242.     lda #2
  243.     sta (fi),y
  244.    
  245.     jmp *
  246.    
  247. RND SUBROUTINE
  248.     lda random+1
  249.     sta temp1
  250.     lda random
  251.     asl
  252.     rol temp1
  253.     asl
  254.     rol temp1
  255.     clc
  256.     adc random
  257.     pha
  258.     lda temp1
  259.     adc random+1
  260.     sta random+1
  261.     pla
  262.     adc #$11
  263.     sta random
  264.     lda random+1
  265.     adc #$36
  266.     sta random+1
  267.     rts
  268.    
  269. aarr    DC.B 253, 175, 2, 80
  270. sc      DC.W 1024
  271. j       DC.B 0
  272. x       DC.B 0
  273. random  
  274.         DC.B %10011101,%01011011
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement