Advertisement
yugorin

rastry v5

Jun 19th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :BasicUpstart2(main)
  2. //----------------------------------------------------------
  3. // Code for creating the breakpoint file sent to Vice/C64Debugger
  4. //----------------------------------------------------------
  5. .var _useBinFolderForBreakpoints = cmdLineVars.get("usebin") == "true"
  6. .var _createDebugFiles = cmdLineVars.get("afo") == "true"
  7. .print "File creation " + [_createDebugFiles
  8.     ? "enabled (creating breakpoint file)"
  9.     : "disabled (no breakpoint file created)"]
  10. .var brkFile
  11. .if(_createDebugFiles) {
  12.     .if(_useBinFolderForBreakpoints)
  13.         .eval brkFile = createFile("bin/breakpoints.txt")
  14.     else
  15.         .eval brkFile = createFile("breakpoints.txt")
  16. }
  17.  
  18. .macro break() {
  19. .if(_createDebugFiles) {
  20.     .eval brkFile.writeln("break " + toHexString(*))
  21.     }
  22. }
  23.  
  24. // For C64Debugger v0.54 (2016/09/03)
  25. .macro setbkg(color) {
  26. .if(_createDebugFiles) {
  27.     .eval brkFile.writeln("setbkg " + toHexString(*) + " " + color)
  28.     }
  29. }
  30.  
  31. //Because Kick Assembler has to be run with the -afo switch to be able to write breakpoints to a file, we can use this to enable "debugger" specific code when build with Shift-F7 or Shift-F5, ie:
  32.  
  33. .const debug = cmdLineVars.get("afo") == "true"
  34.  
  35. .if (debug) {
  36.   inc $d020
  37. }
  38.  
  39. .label border_color = $d020
  40. .label screen_memory = $0400
  41. .label memory_setup_register = $d018
  42.  
  43. .label screen_control_register1 = $d011
  44. .label vic2_rasterline_register = $d012
  45. .label character_rom = $d000
  46.  
  47.  
  48. * = $a20 "Zmienne"
  49. licznik:
  50. .byte $0
  51. gora:
  52. .byte $0
  53. licznik2:
  54. .byte $1
  55.  
  56. licznik3:
  57. .byte $1
  58. predkosc:
  59. .byte $2
  60.  
  61. * = $900 "program"
  62.  
  63. main:
  64. //  jsr $e544
  65. //:break()
  66.  
  67.          
  68.         lda #BLACK
  69.         sta $d020
  70.         sta $d021
  71.         sei       //disable maskable IRQs
  72.  
  73.         lda #$7f
  74.         sta $dc0d //disable timer interrupts which can be generated by the two CIA chips
  75.         sta $dd0d //the kernal uses such an interrupt to flash the cursor and scan the keyboard, so we better
  76.           //stop it.
  77.  
  78.         lda $dc0d//;by reading this two registers we negate any pending CIA irqs.
  79.         lda $dd0d //if we don't do this, a pending CIA irq might occur after we finish setting up our irq.
  80.          //;we don't want that to happen.
  81.  
  82.         lda #$01 //;this is how to tell the VICII to generate a raster interrupt
  83.         sta $d01a
  84.  
  85.         lda #$47 //;this is how to tell at which rasterline we want the irq to be triggered
  86.         sta $d012
  87.  
  88.         lda #$1b  //as there are more than 256 rasterlines, the topmost bit of $d011 serves as
  89.         sta $d011 //the 9th bit for the rasterline we want our irq to be triggered.
  90.          //;here we simply set up a character screen, leaving the topmost bit 0.
  91.  
  92. //      lda #$35  //we turn off the BASIC and KERNAL rom here
  93.     //  sta $01   //the cpu now sees RAM everywhere except at $d000-$e000, where still the registers of
  94.           //SID/VICII/etc are visible
  95.  
  96.     lda #<irq   // nastavit LO byte adresy
  97.     sta $0314   // na LO adresu IRQ - preruseni
  98.     lda #>irq   // nastavit HI byte adresy
  99.     sta $0315   // na HI adresu IRQ - preruseni
  100.     cli // vypnout preruseni
  101.     //rts   // skoncit program
  102.     //  cli      //;enable maskable interrupts again
  103.        
  104.         jmp *    //;we better don't RTS, the ROMS are now switched off, there's no way back to the system
  105.            
  106.            
  107.  irq:  
  108.          inc $d019          
  109.          linia1:
  110.         lda #$6b    // zaladuj do akku $6b
  111. !loop:     
  112.         cmp $d012       // porownaj z rejestrem rastra
  113.         bne !loop-      // Branch Not Equal? to lec do loop i czekaj dalej
  114.  
  115.  
  116. //:break()
  117.         bit $00         // ok mamy 6B. Te bit $00 i nop nie robia nic poza docyklowaniem rastra. bit $00 ma 3 cykle
  118.         bit $00            
  119.         bit $00
  120.         bit $00
  121.         bit $00
  122.         nop             // nop ma 2 cykle
  123.        
  124.         ldy #$00        // tu zaczyna sie petla zaladuj do rejestru y = 0
  125. !kolor:        
  126.         ldx kolor,y         // zaladuj pierwszy bajt z tablicy kolor + y
  127.         stx $d021           // zapisz w rejestrze obrazu (paper). Ta instrukcja wykonuje sie caly czas, az do nastepnego kolory
  128.         ldx tablica,y       // zaladuj pierwszy bajt z tablicy cyklowania (jedna linijka to 63 cykle co 8 linii)
  129. !loop:  dex                 // wartosc Y jest np. 8 - czyli petla ma sie wykonac 8 razy, zeby przelecialo 63 cykle
  130.         bne !loop-          // Y = 0? Nie idz do loop- (czyli pierwsze na gorze)
  131.         iny                 // Tak? Zwieksz Y
  132.         cpy #$24            // Czy Y=$24?
  133.         bne !kolor-         // Nie - idz i wez kolejny kolor z tablicy kolorow jak i z tablicy opoznien
  134. linia2:    
  135.  
  136.         lda #$90                // bylo juz Y=24? to zaladuj $90
  137.         sta $d012               // i zapisz w rejestrze rastra
  138.  !loop:
  139.         cmp $d012               // i znow sprawdz czy jest $90, nie to czekaj tak to
  140.         bne !loop-
  141.        
  142.        
  143.         lda #BLACK              // zaladuj czarny i zmien papier na czarny
  144.         sta $d021               // to ta instrukcja. Czyli od $90 do (po przekreceniu licznika) linii 6B na gorze ma byc czarny
  145.  
  146.  
  147.         pla                 // te sa niewazne dla Ciebie
  148.         tay
  149.         pla
  150.         tax
  151.         pla
  152.  
  153. kopia_gora:
  154. //:break()
  155.     lda licznik2
  156.     beq startuj_gora
  157.     jmp czekaj
  158. przesuniecie_gora:
  159. startuj_gora:  
  160.     ldy #10                
  161. !loop:
  162.     lda gora
  163.     cmp #1
  164.     beq przesuniecie_dol
  165. x1:    
  166.  
  167. copy:       lda kolor,y
  168.  
  169.            
  170.        
  171.         sta kolor-1,y
  172.         iny
  173.         cpy #26
  174.         bne !loop- 
  175.         inc licznik
  176.         lda licznik
  177.         cmp #10    
  178.         bne wyjscie_irq_gora
  179.  
  180.         inc gora
  181.         lda gora       
  182.         cmp #1     
  183.         beq wyjscie_irq_zwykle_gora
  184.  
  185.  
  186.        
  187. przesuniecie_dol:
  188. //:break()
  189.     lda licznik3
  190.     beq startuj_dol
  191.     jmp czekaj3
  192.  
  193. kopia_dol:
  194.    
  195.  
  196. startuj_dol:   
  197.     ldy #16
  198. !loop:
  199.     lda gora
  200.     cmp #0
  201.     beq przesuniecie_gora
  202.    
  203. x2:
  204.         lda kolor-2,y
  205.         sta kolor-1,y
  206.         dey
  207.         cpy #00
  208.         bne !loop- 
  209.         inc licznik
  210.         lda licznik
  211.         cmp #10    
  212.         bne wyjscie_z_irq_dol
  213.  
  214.         dec gora
  215.         lda gora       
  216.         cmp #0     
  217.         beq wyjscie_irq_zwykle_dol  
  218.    
  219.  
  220. wyjscie_irq_gora:
  221.        
  222.     dec x1+1
  223.     dec x1+4
  224.     lda predkosc
  225.     sta licznik2
  226.     rti
  227.  
  228. wyjscie_z_irq_dol:
  229.     inc x2+1
  230.     inc x2+4
  231.     lda predkosc
  232.     sta licznik3
  233.     rti
  234.  
  235. wyjscie_irq_zwykle_dol:
  236.     lda #0
  237.     sta licznik
  238.     lda #$e0
  239.     sta x1+1
  240.     lda #$df
  241.     sta x1+4
  242.     rti
  243.  
  244. wyjscie_irq_zwykle_gora:
  245.     lda #0
  246.     sta licznik
  247.     lda #$de
  248.     sta x2+1
  249.     lda #$df
  250.     sta x2+4
  251.     rti
  252.  
  253. czekaj:
  254.         dec licznik2   
  255.         rti
  256.  
  257. czekaj3:   
  258.         dec licznik3   
  259.         rti
  260.    
  261.    
  262. * = $0ce0 "Kolory"
  263. kolor:
  264.         .byte 0,0,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  265.        
  266.  
  267. * = $c00 "Tablica cyklowania"      
  268. tablica:       
  269.         .byte 8,9,9,9,9,9,9,1,8,9,9,9,9,9,9,1,8,9,9,9,9,9,9,1,8,9,9,9,9,9,9,1,8,9,9,9,9,9,9,1,8,9,9,9,9,9,9,1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement