Advertisement
yugorin

rastry v4

Jun 18th, 2017
113
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. * = $9f0 "Zmienne"
  49. licznik:
  50. .byte $0
  51. gora:
  52. .byte $0
  53.  
  54. * = $900 "program"
  55.  
  56. main:
  57. //  jsr $e544
  58. //:break()
  59.  
  60.          
  61.         lda #BLACK
  62.         sta $d020
  63.         sta $d021
  64.         sei       //disable maskable IRQs
  65.  
  66.         lda #$7f
  67.         sta $dc0d //disable timer interrupts which can be generated by the two CIA chips
  68.         sta $dd0d //the kernal uses such an interrupt to flash the cursor and scan the keyboard, so we better
  69.           //stop it.
  70.  
  71.         lda $dc0d//;by reading this two registers we negate any pending CIA irqs.
  72.         lda $dd0d //if we don't do this, a pending CIA irq might occur after we finish setting up our irq.
  73.          //;we don't want that to happen.
  74.  
  75.         lda #$01 //;this is how to tell the VICII to generate a raster interrupt
  76.         sta $d01a
  77.  
  78.         lda #$47 //;this is how to tell at which rasterline we want the irq to be triggered
  79.         sta $d012
  80.  
  81.         lda #$1b  //as there are more than 256 rasterlines, the topmost bit of $d011 serves as
  82.         sta $d011 //the 9th bit for the rasterline we want our irq to be triggered.
  83.          //;here we simply set up a character screen, leaving the topmost bit 0.
  84.  
  85. //      lda #$35  //we turn off the BASIC and KERNAL rom here
  86.     //  sta $01   //the cpu now sees RAM everywhere except at $d000-$e000, where still the registers of
  87.           //SID/VICII/etc are visible
  88.  
  89.     lda #<irq   // nastavit LO byte adresy
  90.     sta $0314   // na LO adresu IRQ - preruseni
  91.     lda #>irq   // nastavit HI byte adresy
  92.     sta $0315   // na HI adresu IRQ - preruseni
  93.     cli // vypnout preruseni
  94.     //rts   // skoncit program
  95.     //  cli      //;enable maskable interrupts again
  96.        
  97.         jmp *    //;we better don't RTS, the ROMS are now switched off, there's no way back to the system
  98.            
  99.            
  100.  irq:  
  101.          inc $d019          
  102.          linia1:
  103.         lda #$6b    // zaladuj do akku $6b
  104. !loop:     
  105.         cmp $d012       // porownaj z rejestrem rastra
  106.         bne !loop-      // Branch Not Equal? to lec do loop i czekaj dalej
  107. //:break()
  108.         bit $00         // ok mamy 6B. Te bit $00 i nop nie robia nic poza docyklowaniem rastra. bit $00 ma 3 cykle
  109.         bit $00            
  110.         bit $00
  111.         bit $00
  112.         bit $00
  113.         nop             // nop ma 2 cykle
  114.        
  115.         ldy #$00        // tu zaczyna sie petla zaladuj do rejestru y = 0
  116. !kolor:        
  117.         ldx kolor,y         // zaladuj pierwszy bajt z tablicy kolor + y
  118.         stx $d021           // zapisz w rejestrze obrazu (paper). Ta instrukcja wykonuje sie caly czas, az do nastepnego kolory
  119.         ldx tablica,y       // zaladuj pierwszy bajt z tablicy cyklowania (jedna linijka to 63 cykle co 8 linii)
  120. !loop:  dex                 // wartosc Y jest np. 8 - czyli petla ma sie wykonac 8 razy, zeby przelecialo 63 cykle
  121.         bne !loop-          // Y = 0? Nie idz do loop- (czyli pierwsze na gorze)
  122.         iny                 // Tak? Zwieksz Y
  123.         cpy #$24            // Czy Y=$24?
  124.         bne !kolor-         // Nie - idz i wez kolejny kolor z tablicy kolorow jak i z tablicy opoznien
  125. linia2:    
  126.  
  127.         lda #$90                // bylo juz Y=24? to zaladuj $90
  128.         sta $d012               // i zapisz w rejestrze rastra
  129.  !loop:
  130.         cmp $d012               // i znow sprawdz czy jest $90, nie to czekaj tak to
  131.         bne !loop-
  132.        
  133.        
  134.         lda #BLACK              // zaladuj czarny i zmien papier na czarny
  135.         sta $d021               // to ta instrukcja. Czyli od $90 do (po przekreceniu licznika) linii 6B na gorze ma byc czarny
  136.  
  137.  
  138.         pla                 // te sa niewazne dla Ciebie
  139.         tay
  140.         pla
  141.         tax
  142.         pla
  143.  
  144. przesuniecie_gora:
  145. //:break()  
  146.     ldy #10                
  147.    
  148. !loop:
  149.     lda gora
  150.     cmp #1
  151.     beq przesuniecie_dol
  152.  
  153.  
  154. x1:    
  155.         lda kolor,y
  156.         sta kolor-1,y
  157.         iny
  158.         cpy #26
  159.         bne !loop- 
  160.         inc licznik
  161.         lda licznik
  162.         cmp #10    
  163.         bne wyjscie_irq_gora
  164.  
  165.         inc gora
  166.         lda gora       
  167.         cmp #1     
  168.         beq wyjscie_irq_zwykle_gora
  169.        
  170. przesuniecie_dol:
  171.    
  172.     ldy #16
  173. !loop:
  174.     lda gora
  175.     cmp #0
  176.     beq przesuniecie_gora
  177.    
  178. x2:
  179.         lda kolor-2,y
  180.         sta kolor-1,y
  181.         dey
  182.         cpy #00
  183.         bne !loop- 
  184.         inc licznik
  185.         lda licznik
  186.         cmp #10    
  187.         bne wyjscie_z_irq_dol
  188.  
  189.         dec gora
  190.         lda gora       
  191.         cmp #0     
  192.         beq wyjscie_irq_zwykle_dol  
  193.    
  194.  
  195. wyjscie_irq_gora:
  196.        
  197.     dec x1+1
  198.     dec x1+4
  199.     rti
  200.  
  201. wyjscie_z_irq_dol:
  202.     inc x2+1
  203.     inc x2+4
  204.     rti
  205.  
  206. wyjscie_irq_zwykle_dol:
  207.     lda #0
  208.     sta licznik
  209.     lda #$e0
  210.     sta x1+1
  211.     lda #$df
  212.     sta x1+4
  213.     rti
  214.  
  215. wyjscie_irq_zwykle_gora:
  216.     lda #0
  217.     sta licznik
  218.     lda #$de
  219.     sta x2+1
  220.     lda #$df
  221.     sta x2+4
  222.     rti
  223.        
  224.    
  225. * = $0ce0 "Kolory"
  226. kolor:
  227.         .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
  228.        
  229.  
  230. * = $c00 "Tablica cyklowania"      
  231. tablica:       
  232.         .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