daily pastebin goal
51%
SHARE
TWEET

4way.bas

a guest Nov 17th, 2013 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.  dim cadd = c
  3.  dim badd = b
  4.  dim fbyte = f
  5.  dim radd = r
  6.  dim wx = x
  7.  dim wy = y
  8.  
  9.  COLUBK = $20
  10.  COLUPF = $40
  11.  
  12.  
  13. main
  14.  
  15.  if joy0up    then wy = (wy - 1) &  15 : gosub setup_addresses : goto scroll_up
  16.  if joy0down  then wy = (wy + 1) &  15 : gosub setup_addresses : goto scroll_down
  17. left_right
  18.  if joy0right then wx = (wx + 1) & 127 : gosub setup_addresses : goto scroll_right
  19.  if joy0left  then wx = (wx - 1) & 127 : gosub setup_addresses : goto scroll_left
  20. draw
  21.  drawscreen
  22.  goto main
  23.  
  24.  
  25. scroll_up
  26.  for p = 40 to 0 step -4
  27.  var4[p]=var0[p]
  28.  var5[p]=var1[p]
  29.  var6[p]=var2[p]
  30.  var7[p]=var3[p]
  31.  next  
  32.  
  33.  rem if badd, bit address is 0 then we're aligned
  34.  rem no need to shift
  35.  if !badd then gosub fill_top : goto left_right
  36.  if badd > 3 then goto shift_top_right
  37.  
  38.  gosub fill_top
  39.  fbyte = fill(4)
  40.  
  41.  for i = 1 to badd
  42.  asm
  43.  asl fbyte
  44.  ror var3
  45.  rol var2
  46.  ror var1
  47.  rol var0
  48. end
  49.  next
  50.  
  51.  goto left_right
  52.  
  53. shift_top_right
  54.  fbyte = fill(0) : j = 8 - badd
  55.  
  56.  cadd = (cadd + 1) & 15 : gosub fill_top
  57.  
  58.  for i = 1 to j
  59.  asm
  60.  lsr fbyte
  61.  ror var0
  62.  rol var1
  63.  ror var2
  64.  rol var3
  65. end
  66.  next
  67.  
  68.  goto left_right
  69.  
  70.  
  71. scroll_down
  72.  for p = 0 to 40 step 4
  73.  var0[p]=var4[p]
  74.  var1[p]=var5[p]
  75.  var2[p]=var6[p]
  76.  var3[p]=var7[p]
  77.  next  
  78.  
  79.  rem current row + (11*16 bytes/row) to fill in the bottom
  80.  radd = radd + 176
  81.  
  82.  rem if badd, thr bit address is 0 then we're aligned
  83.  rem no need to shift
  84.  if !badd then  gosub fill_bot : goto left_right
  85.  
  86.  rem if badd > 3 then shifting right needs fewer shifts
  87.  if badd > 3 then goto shift_bot_right
  88.  
  89.  gosub fill_bot
  90.  fbyte = fill(4)
  91.  
  92.  for i = 1 to badd
  93.  asm
  94.  asl fbyte
  95.  ror var47
  96.  rol var46
  97.  ror var45
  98.  rol var44
  99. end
  100.  next
  101.  
  102.  goto left_right
  103.  
  104. shift_bot_right
  105.  rem get the fill byte then bump the column to fill
  106.  rem the line by shifting right
  107.  fbyte = fill(0) : cadd = (cadd + 1) & 15 : j = 8 - badd
  108.  
  109.  gosub fill_bot
  110.  
  111.  for i = 1 to j
  112.  asm
  113.  lsr fbyte
  114.  ror var44
  115.  rol var45
  116.  ror var46
  117.  rol var47
  118. end
  119.  next
  120.  
  121.  goto left_right
  122.  
  123.  
  124. scroll_left
  125.  for i = 0 to 44 step 4
  126.  fbyte = (i * 4 + radd) | cadd : fbyte = world[fbyte] & setbits[badd]
  127.  if fbyte then fbyte = 1
  128.  asm
  129.  ldx i
  130.  ror fbyte
  131.  ror var0,x
  132.  rol var0+1,x
  133.  ror var0+2,x
  134.  rol var0+3,x
  135. end
  136.  next
  137.  
  138.  goto draw
  139.  
  140.  
  141. scroll_right
  142.  rem the fill in pixel is the current wx + 31, 32 pixels/screen,
  143.  rem wx is at screen 0
  144.  fbyte = (wx + 31) & 127 : cadd = fbyte / 8 : badd = fbyte & 7
  145.  for i = 0 to 44 step 4
  146.  fbyte = (i * 4 + radd) | cadd : fbyte = world[fbyte] & setbits[badd]
  147.  if fbyte then fbyte = 1
  148.  asm
  149.  ldx i
  150.  ror fbyte
  151.  ror var0+3,x
  152.  rol var0+2,x
  153.  ror var0+1,x
  154.  rol var0,x
  155. end
  156.  next
  157.  
  158.  goto draw
  159.  
  160. setup_addresses
  161.  cadd = wx / 8 : badd = wx & 7 : radd = wy * 4 * 4
  162.  return
  163.  
  164. fill_bot
  165.  var44 = fill(0)
  166.  var45 = fill(1) : var45 = rev(var45)
  167.  var46 = fill(2)
  168.  var47 = fill(3) : var47 = rev(var47)
  169.  return
  170.  
  171. fill_top
  172.  var0 = fill(0)
  173.  var1 = fill(1) : var1 = rev(var1)
  174.  var2 = fill(2)
  175.  var3 = fill(3) : var3 = rev(var3)
  176.  return
  177.  
  178.  rem function fill
  179.  rem asm
  180.  rem clc
  181.  rem adc cadd
  182.  rem and #$0F
  183.  rem adc radd
  184.  rem tax
  185.  rem lda world,x
  186.  rem rts
  187.  rem end
  188.  
  189.  rem adds the parameter to the (byte)column with
  190.  rem wrapping and gets that byte in the current (world) row
  191.  function fill()
  192.  temp1 = ((temp1 + cadd) & 15) | radd
  193.  temp1 = world[temp1]
  194.  return
  195.  
  196.  function rev()
  197.  temp2 = temp1 & $0F
  198.  temp1 = temp1 / 16
  199.  temp1 = revhi[temp2] | revlo[temp1]
  200.  return
  201.  
  202.  data revhi
  203.  $00, $80, $40, $C0, $20, $A0, $60, $E0
  204.  $10, $90, $50, $D0, $30, $B0, $70, $F0
  205. end
  206.  
  207.  data revlo
  208.  $00, $08, $04, $0C, $02, $0A, $06, $0E
  209.  $01, $09, $05, $0D, $03, $0B, $07, $0F
  210. end
  211.  
  212.  data setbits
  213.  $80, $40, $20, $10, $08, $04, $02, $01
  214. end
  215.  
  216.  data world
  217.  %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111
  218.  %10000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  219.  %10000000, %00000000, %00000000, %00000000, %00000000, %00100000, %01000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  220.  %10000011, %10000000, %00000000, %00000000, %10000000, %00100000, %10000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  221.  %10000100, %10000000, %00000000, %00000000, %11000000, %00010001, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  222.  %10001000, %10000000, %00000000, %00000001, %00100000, %00001010, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  223.  %10010000, %10001000, %00000100, %00000010, %00010000, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  224.  %10011111, %10001000, %00000100, %00000100, %00001000, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  225.  %10000000, %10001000, %10000100, %00001000, %00000100, %00001000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  226.  %10000000, %10001001, %01000100, %00010111, %11111110, %00001000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  227.  %10000000, %10001010, %00100100, %00100000, %00000010, %00010000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  228.  %10000000, %10001100, %00010100, %01000000, %00000010, %00100000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  229.  %10000000, %00001000, %00001100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  230.  %10000000, %00000000, %00000100, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  231.  %10000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000000, %00000001
  232.  %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111, %11111111
  233. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top