home *** CD-ROM | disk | FTP | other *** search
/ Loadstar - Compleat Programmer / comprog1.d81 / swap.s < prev    next >
Text File  |  2022-08-28  |  2KB  |  120 lines

  1. open =$ffc0
  2. readst =$ffb7
  3. setlfs =$ffba
  4. setnam =$ffbd
  5. load =$ffd5
  6. getin =$ffe4
  7. clrchn =$ffcc
  8. close =$ffc3   ;a
  9. chrin =$ffcf
  10. chkout =$ffc9  ;x
  11. chkin =$ffc6   ;x
  12. plot =$fff0
  13. chrout =$ffd2
  14. color'pointer =243
  15. screen'line'pointer =209
  16. print'number =$bdcd ;x,a
  17. clear'line =59903
  18. background =53281
  19. border =53280
  20. unlisten =$ffae
  21. clall =$ffe7
  22. source =251
  23. end =253
  24. destination =$14
  25. ;dis
  26. .org $c000
  27. .mem
  28. ;obj "@0:swapymem"
  29. ;by Jeff Jones
  30. ;sys source,end+1,dest
  31. ;copy =addr
  32. ;swap =addr+7
  33. ;ROM in copy =addr+14
  34.  
  35.  
  36. lda #0      ;regular copy
  37. sta 212     ;just using this as a flag
  38. sec
  39. bcs get'numbers
  40. side'door lda #64 ;swap mode
  41. sta 212
  42. sec
  43. bcs get'numbers
  44.  
  45. trap'door lda #128 ;original rom on
  46. sta 212
  47.  
  48. get'numbers jsr $aefd
  49. jsr $ad8a
  50. jsr $b7f7
  51. sty source
  52. sta source+1
  53.  
  54. jsr $aefd
  55. jsr $ad8a
  56. jsr $b7f7
  57.  
  58. sty end
  59. sta end+1
  60.  
  61. jsr $aefd
  62. jsr $ad8a
  63. jsr $b7f7
  64.  
  65. lda end+1
  66. cmp source+1  ;is end lower than source?
  67. beq next'test 
  68. bcs okay
  69. bcc quit      ;if so, bail out
  70.  
  71. next'test lda end
  72. cmp source
  73. bcc quit
  74. beq quit
  75.  
  76. okay bit 212  ;leave ROM alone?
  77. bmi +
  78.  
  79. sei    ;don't interrupt this groove
  80. lda 1
  81. pha           ;stash I/O status
  82. lda #$74      ;knock 'em all out
  83. sta 1
  84.  
  85. + ldy #0 
  86. - lda (source),y
  87. bit 212       ;Swap?
  88. bvc +         ;if clear then nope
  89. pha
  90. lda (destination),y
  91. sta (source),y
  92. pla
  93. + sta (destination),y
  94.  
  95. inc source    ;increment source and dest
  96. bne +
  97. inc source+1
  98. + inc destination
  99. bne +
  100. inc destination+1
  101.  
  102. + lda source+1 ;finis?
  103. cmp end+1
  104. bcc -    ;not finished by page
  105.  
  106. lda source
  107. cmp end
  108. bcc -    ;just plain not finished
  109.  
  110. bit 212  ;was I/O reg stashed?
  111. bmi quit ;if not then don't restore
  112.  
  113. pla      ;get back original I/O reg
  114. sta 1    ;back to normal
  115. cli      ;interrupts back on
  116. quit lda #0
  117. sta 212  ;make sure quote mode is off
  118. rts
  119.  
  120.