Scroll.asm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. BasicUpstart2(mainProg)
  2. .const scrollLine = $0400+24*40
  3. //----------------------------------------------------
  4. // Main Program
  5. //----------------------------------------------------
  6. *=$1000
  7. mainProg: { // <- Here we define a scope
  8. sei
  9. lda #$17
  10. sta $d018
  11. // Wait for line $f2 and set d016
  12. loop1: lda #$f2 //<- Here we define 'loop1'
  13. cmp $d012
  14. bne loop1
  15. jsr setScrollD016
  16. // Wait for line $ff and prepare next frame
  17. loop2: lda #$ff // <- Inside the scope labels can collide so we use 'loop2'
  18. cmp $d012
  19. bne loop2
  20. lda #$c8
  21. sta $d016
  22. jsr moveScroll
  23. jmp loop1
  24. }
  25. //----------------------------------------------------
  26. // Scroll Routines
  27. //----------------------------------------------------
  28. setScrollD016: {
  29. value: lda #0
  30. and #$07
  31. ora #$c0
  32. sta $d016
  33. rts
  34. }
  35. moveScroll: {
  36. // Step d016
  37. dec setScrollD016.value+1 //<- We can access labels of other scopes this way!
  38. lda setScrollD016.value+1
  39. and #$07
  40. cmp #$07
  41. bne exit
  42. // Move screen chars
  43. ldx #0
  44. loop1: lda scrollLine+1,x // <- Since 'loop1' is in a new scope it doesn't collide with the first 'loop1' label
  45. sta scrollLine,x
  46. inx
  47. cpx #39
  48. bne loop1
  49. // Print new char
  50. count: ldx #0
  51. lda text,x
  52. sta scrollLine+39
  53. inx
  54. lda text,x
  55. cmp #$ff
  56. bne over1
  57. ldx #0
  58. over1: stx count+1
  59. exit: rts
  60. text: .text "Hello friends, how are we doing today. Hope you enjoy this scoping demo. Now get ready for pseudocommands.... "
  61. .byte $ff
  62. }