Advertisement
yugorin

intro na 40 działa

Nov 9th, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. :BasicUpstart2(main)
  2.  
  3. .label PamiecEkranu = $4400
  4. .label Ramka = $d020
  5. .label Ekran = $d021
  6.  
  7. .label memory_setup_register_D018 = $d018
  8. .label VIC_bank = $dd00
  9. //----------------------------------------------------------
  10. // Code for creating the breakpoint file sent to Vice.
  11. //----------------------------------------------------------
  12. .var _useBinFolderForBreakpoints = cmdLineVars.get("usebin") == "true"
  13. .var _createDebugFiles = cmdLineVars.get("afo") == "true"
  14. .print "File creation " + [_createDebugFiles
  15.     ? "enabled (creating breakpoint file)"
  16.     : "disabled (no breakpoint file created)"]
  17. .var brkFile
  18. .if(_createDebugFiles) {
  19.     .if(_useBinFolderForBreakpoints)
  20.         .eval brkFile = createFile("bin/breakpoints.txt")
  21.     else
  22.         .eval brkFile = createFile("breakpoints.txt")
  23. }
  24. .macro break() {
  25. .if(_createDebugFiles) {
  26.     .eval brkFile.writeln("break " + toHexString(*))
  27.     }
  28. }
  29. //------------------------------------------------------
  30.  
  31. .macro trybTekstowy () {
  32. lda #$1b
  33. sta $d011
  34. lda #$c8
  35. sta $d016
  36.        
  37. }
  38.  
  39. .macro trybGraficzny()
  40. {
  41.     lda #$3b
  42.      sta $d011        
  43.  
  44.  
  45.   lda #$08
  46.   sta $d016
  47. }
  48.  
  49. .macro wybierz_index_charmem_pamieci_D018(index) {
  50.   lda memory_setup_register_D018
  51.   and #%11110001 // ustawia tylko bity oznaczone 0
  52.   ora #[index << 1]  // wybiera numer strony pamięci według mapy C64 z netu
  53.   sta memory_setup_register_D018 // zapisuje do $D018
  54. }
  55.  
  56. .macro wybierz_index_screen_memory_pamieci_D018(index) {
  57.   lda memory_setup_register_D018
  58.   and #%00001111 // ustawia tylko bity oznaczone 0
  59.   ora #[index << 4]  // wybiera numer strony pamięci według mapy C64 z netu
  60.   sta memory_setup_register_D018 // zapisuje do $D018
  61. }
  62.  
  63.  
  64. .macro wybierz_index_banku_pamieci_VIC_DD00(index) {
  65.     lda VIC_bank  
  66.     and #%11111100 // zeruje bit #0 i #1
  67.     ora #[index ^ %00000011] // XOR na wartości z index
  68.     sta VIC_bank
  69. }
  70.  
  71. .macro ClearScreen(PamiecEkranu, clearByte) {
  72.   lda #clearByte
  73.   ldx #0
  74. !loop:
  75.   sta PamiecEkranu, x
  76.   sta PamiecEkranu + $100, x
  77.   sta PamiecEkranu + $200, x
  78.   sta PamiecEkranu + $300, x
  79.   inx
  80.   bne !loop-
  81. }
  82.  
  83. .macro ClearScreen_DOL(PamiecEkranu, clearByte) {
  84.   lda #clearByte
  85.   ldx #0
  86. !loop:
  87.   sta PamiecEkranu+633, x
  88.   sta PamiecEkranu+633+100, x
  89.  
  90.   inx
  91.   bne !loop-
  92. }
  93.  
  94. .pseudocommand pause cycles {
  95.   :ensureImmediateArgument(cycles)
  96.   .var x = floor(cycles.getValue())
  97.   .if (x<2) .error "Cant make a pause on " + x + " cycles"
  98.  
  99.   // Take care of odd cyclecount  
  100.   .if ([x&1]==1) {
  101.     bit $00
  102.     .eval x=x-3
  103.   }
  104.  
  105.   // Take care of the rest
  106.   .if (x>0)
  107.     :nop #x/2
  108. }
  109.  
  110.  
  111. //---------------------------------
  112. // repetition commands
  113. //---------------------------------
  114. .macro ensureImmediateArgument(arg) {
  115.   .if (arg.getType()!=AT_IMMEDIATE) .error "The argument must be immediate!"
  116. }
  117. .pseudocommand asl x {
  118.   :ensureImmediateArgument(x)
  119.   .for (var i=0; i<x.getValue(); i++) asl
  120. }
  121. .pseudocommand lsr x {
  122.   :ensureImmediateArgument(x)
  123.   .for (var i=0; i<x.getValue(); i++) lsr
  124. }
  125. .pseudocommand rol x {
  126.   :ensureImmediateArgument(x)
  127.   .for (var i=0; i<x.getValue(); i++) rol
  128. }
  129. .pseudocommand ror x {
  130.   :ensureImmediateArgument(x)
  131.   .for (var i=0; i<x.getValue(); i++) ror
  132. }
  133.  
  134. .pseudocommand pla x {
  135.   :ensureImmediateArgument(x)
  136.   .for (var i=0; i<x.getValue(); i++) pla
  137. }
  138.  
  139. .pseudocommand nop x {
  140.   :ensureImmediateArgument(x)
  141.   .for (var i=0; i<x.getValue(); i++) nop
  142. }
  143.  
  144. main:
  145.  
  146.           sei         //wyłączenie flafi przerwania
  147.           lda #$00
  148.           jsr $1000
  149.  
  150.     :wybierz_index_banku_pamieci_VIC_DD00(1)
  151.  
  152.            
  153.             ldy #$7f    ////; $7f = %01111111
  154.             sty $dc0d   ////; wyłączamy timer CIA
  155.             sty $dd0d   ////; ; wyłączamy timer CIA
  156.             lda $dc0d   ////; kasuje wszystki przerwania CIA w kolejce
  157.             lda $dd0d   ////; kasuje wszystki przerwania CIA w kolejce
  158.          
  159.             lda #$01    ////; Set Interrupt Request Mask...
  160.             sta $d01a   ////; ...we want IRQ by Rasterbeam
  161.  
  162.             lda #<irq1   ////; wskaźnik to IRQ
  163.             ldx #>irq1
  164.             sta $314    ////; zapisz tutaj
  165.             stx $315  
  166.  
  167.             lda #$00    ////; ustawiam pierwsze przerwanie na raster 0
  168.             sta $d012
  169.             lda $d011   ////; ustawiam 9 bit z $d011 na 0            
  170.             and #$7f    ////;
  171.             sta $d011   ////;                                        
  172.             jsr obrazek
  173.     :ClearScreen(PamiecEkranu,$20)
  174.             cli         ////; clear interrupt disable flag
  175.          
  176.  
  177.             jsr wyswietl_text_1
  178.             jsr wyswietl_text_2
  179.  
  180.             :ClearScreen_DOL(PamiecEkranu,$20)
  181.  
  182.             jsr wyswietl_text_3
  183.  
  184.             :ClearScreen_DOL(PamiecEkranu,$20)
  185.  
  186.             jsr wyswietl_text_4
  187.             jmp *       ////; infinite loop
  188.  
  189.  
  190. ////;============================================================
  191. ////;    custom interrupt routine
  192. ////;============================================================
  193.  
  194. irq1:    inc $d019
  195.   jsr $1003
  196.         lda #$b1
  197.         sta $d012
  198.         //:trybTekstowy()
  199.  
  200. //        :wybierz_index_charmem_pamieci_D018(2)
  201.        
  202.      
  203.  
  204.         lda #<irq2
  205.         sta $0314
  206.         lda #>irq2
  207.         sta $0315
  208.         pla
  209.         tay
  210.         pla
  211.         tax
  212.         pla
  213.         rti
  214.        
  215. irq2:   inc $d019
  216.         lda #$2f
  217.         sta $d012
  218. :break()
  219.         :trybTekstowy()
  220.         :wybierz_index_charmem_pamieci_D018(1)
  221.        
  222.  
  223.         lda #<irq3
  224.         sta $0314
  225.         lda #>irq3
  226.         sta $0315
  227.         pla
  228.         tay
  229.         pla
  230.         tax
  231.         pla
  232.         rti
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.        
  240. irq3:  
  241.         inc $d019
  242.         lda #$80
  243.         sta $d012
  244. //        :pause #6
  245.   :trybTekstowy()
  246.  
  247.         :wybierz_index_charmem_pamieci_D018(2)      
  248.         // kod poniej wykonuje się pomiędzy rastrem 34 a 80
  249. ///////////////////////////////////////////////////////////////////////        
  250.  
  251.                       ldy #$00
  252. !cykl:
  253.                       ldx cykle,y
  254. !petla:
  255.                       dex
  256.                       bne !petla-
  257.  
  258.                       lda kolorki,y
  259.                       sta Ekran
  260.                       sta Ramka
  261.                       iny
  262.                       cpy #$0b
  263.                       bne !cykl-    
  264.                       jsr colwash
  265.  
  266.  
  267. ///////////////////////////////////////////////////////////////////////        
  268.  
  269.  
  270.  
  271.  
  272.  
  273.         lda #<irq1
  274.         sta $0314
  275.         lda #>irq1
  276.         sta $0315
  277.         pla
  278.         tay
  279.         pla
  280.         tax
  281.         pla
  282.         rti
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289. ///////////////////////////////////////////////////////////////// wyświetyla tekst na górnym przerwaniu
  290. wyswietl_text_1:
  291.     ldx #$00
  292.  
  293. !petla:
  294.     lda teksty,x
  295.     sta PamiecEkranu,x
  296.     jsr opoznienie
  297.     cpx #119
  298.     beq powrot
  299.     inx
  300.     bne !petla-
  301.  
  302. powrot:  
  303.     rts
  304. ///////////////////////////////////////////////////////////////// wyświetyla tekst na górnym przerwaniu
  305.  
  306.  
  307.  
  308.  
  309. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu
  310. wyswietl_text_2:
  311.     ldx #$00
  312. !petla:
  313.     lda tekst_2,x
  314.     sta PamiecEkranu+640,x
  315.     jsr opoznienie
  316.     cpx #200
  317.     beq !powrot+
  318.     inx
  319.     bne !petla-
  320. !powrot:
  321.     rts
  322. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu
  323.  
  324.  
  325.  
  326. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu - zmiana ekranu
  327. wyswietl_text_3:
  328.     ldx #$00
  329. !petla:
  330.     lda tekst_8,x
  331.     sta PamiecEkranu+845,x
  332.     jsr opoznienie
  333.     cpx #31
  334.     beq !powrot+
  335.     inx
  336.     bne !petla-
  337. !powrot:
  338.     rts
  339. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu - zmiana ekranu
  340.  
  341.  
  342.  
  343. wyswietl_text_4:
  344.     ldx #$00
  345. !petla:
  346.     lda tekst_10,x
  347.     sta PamiecEkranu+640,x
  348.     jsr opoznienie
  349.     cpx #239
  350.     beq !powrot+
  351.     inx
  352.     bne !petla-
  353. !powrot:
  354.     rts
  355.  
  356.  
  357. wyswietl_text_5:
  358.     ldx #$00
  359. !petla:
  360.     lda tekst_15,x
  361.     sta PamiecEkranu+642,x
  362.     jsr opoznienie
  363.     cpx #255
  364.     beq !powrot+
  365.     inx
  366.     bne !petla-
  367. !powrot:
  368.     rts
  369.  
  370. wyswietl_text_6:
  371.     ldx #$00
  372. !petla:
  373.     lda tekst_16,x
  374.     sta PamiecEkranu+880,x
  375.     jsr opoznienie
  376.     cpx #51
  377.     beq !powrot+
  378.     inx
  379.     bne !petla-
  380. !powrot:
  381.     rts
  382.  
  383.  
  384. wyswietl_text_7:
  385.     ldx #$00
  386. !petla:
  387.     lda tekst_17,x
  388.     sta PamiecEkranu+851,x
  389.     jsr opoznienie
  390.     cpx #22
  391.     beq !powrot+
  392.     inx
  393.     bne !petla-
  394. !powrot:
  395.     rts
  396.  
  397. opoznienie:
  398.       txa
  399.       ldx #$00  
  400. petla1:
  401.       ldy #$00
  402. petla2:
  403.       iny
  404.       cpy #$40
  405.       bne petla2
  406.       inx
  407.       cpx #$90
  408.       bne petla1
  409.       tax
  410.       rts
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.        
  421. colwash:   ldx #$4f        //; load x-register with #$27 to work through 0-39 iterations
  422.           lda color+$4f   //; init accumulator with the last color from first color table
  423.  
  424. cycle1:    ldy color-1,x   //; remember the current color in color table in this iteration
  425.           sta color-1,x   //; overwrite that location with color from accumulator
  426.           sta $d800,x     //; put it into Color Ram into column x
  427.           tya             //; transfer our remembered color back to accumulator
  428.           dex             //; decrement x-register to go to next iteration
  429.           bne cycle1      //; repeat if there are iterations left
  430.           sta color+$4f   //; otherwise store te last color from accu into color table
  431.           sta $d800       //; ... and into Color Ram
  432.                          
  433. colwash2:  ldx #$00        //; load x-register with #$00
  434.           lda color2+$4f  //; load the last color from the second color table
  435.  
  436. cycle2:    ldy color2,x    //; remember color at currently looked color2 table location
  437.           sta color2,x    //; overwrite location with color from accumulator
  438.           sta $d828,x     //; ... and write it to Color Ram
  439.           tya             //; transfer our remembered color back to accumulator
  440.           inx             //; increment x-register to go to next iteraton
  441.           cpx #$4f        //; have we gone through 39 iterations yet?
  442.           bne cycle2      //; if no, repeat
  443.           sta color2+$4f  //; if yes, store the final color from accu into color2 table
  444.           sta $d828+$4f   //; and write it into Color Ram
  445.  
  446.           rts             //; return from subroutine
  447.  
  448.  
  449. color:        .byte $09,$09,$02,$02,$08
  450.              .byte $08,$0a,$0a,$0f,$0f
  451.              .byte $07,$07,$01,$01,$01
  452.              .byte $01,$01,$01,$01,$01
  453.              .byte $01,$01,$01,$01,$01
  454.              .byte $01,$01,$01,$07,$07
  455.              .byte $0f,$0f,$0a,$0a,$08
  456.              .byte $08,$02,$02,$09,$09
  457.  
  458. color2:       .byte $09,$09,$02,$02,$08
  459.              .byte $08,$0a,$0a,$0f,$0f
  460.              .byte $07,$07,$01,$01,$01
  461.              .byte $01,$01,$01,$01,$01
  462.              .byte $01,$01,$01,$01,$01
  463.              .byte $01,$01,$01,$07,$07
  464.              .byte $0f,$0f,$0a,$0a,$08
  465.              .byte $08,$02,$02,$09,$09
  466.  
  467.  
  468.  
  469. obrazek:
  470.  
  471.    ldx #$00
  472.    
  473. laduj_obrazek:
  474. //    lda $3f40+$4000,x
  475. //    sta PamiecEkranu,x
  476.     lda $3f40+$4000+256,x
  477.     sta PamiecEkranu+256,x
  478.     lda $3f40+$4000+300,x
  479.     sta PamiecEkranu+300,x
  480. //    lda $3f40+$4000+768,x
  481. //    sta PamiecEkranu+768,x
  482.     dex
  483.     bne laduj_obrazek
  484.     rts
  485.  
  486.  
  487. opoznienie2:
  488.         txa
  489.             ldx #$00   
  490.  
  491. petla1_2:
  492.             ldy #$00
  493.  
  494. petla2_2:
  495.             iny
  496.             cpy #$50
  497.             bne petla2_2
  498.             inx
  499.             cpx #$90
  500.             bne petla1_2
  501.             tax
  502.             rts
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510. opoznienie3:
  511.         txa
  512.             ldx #$00   
  513.  
  514. petla4_1:
  515.             ldy #$00
  516.  
  517. petla4_2:
  518.             iny
  519.             cpy #$ff
  520.             bne petla4_2
  521.             inx
  522.             cpx #$ff
  523.             bne petla4_1
  524.             tax
  525.             rts
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533. teksty:
  534.         .text "     yugorin of samar productions       "
  535.     .text "     prezentuje pierwsze wypociny       "
  536.     .text "    po  30 latach bycia w niebycie      "
  537.  
  538.  
  539.  
  540.  
  541.  
  542. tekst_2:
  543.         .text "nie umiem jeszcze zrobic scrolla, ale to"
  544.         .text "kwestia czasu. bardzo chcialem zrobic   "
  545.         .text "pierwsze 'cos', zeby moc powiedziec     "
  546.         .text "wszystkim, ze po 30 latach jestem tu,   "
  547.         .text "gdzie przerwalem jako dziecko.          "
  548.  
  549. tekst_8:
  550.         .text " nigdy nie zrobilem scrolla :-)     "
  551.  
  552. tekst_10:
  553.  
  554.   .text "dziekuje dkt, isildurowi i slejerkowi za"
  555.   .text "wiare we mnie. calemu samarowi za przy- "
  556.   .text "jecie, jammerowi za opierdol na start za"
  557.   .text "dropboxa. wielkie dzieki mlodszemu bratu"
  558.   .text "programiscie (fucking genius)!! za wiare"
  559.   .text "wsparcie i cierpliwosc do mnie.         "
  560.  
  561.  
  562.  
  563.   tekst_15:
  564.  
  565.   .text " to, ze skubany nie zna asm"
  566.   .text " a tlumaczy mi co robie zle"
  567.   .text " sprawia,ze jestem dumny"
  568.   .text " z niego jak nikt na swiecie."
  569.   .text "namawiam go na kodzenie w asm "
  570.   .text "na c64. zobaczymy co z tego wyjdzie."
  571.   .text "na koniec dziekuje asi i biance "
  572.   .text "za to, ze jeszcze nie zwariowaly "
  573.  
  574.   tekst_16:
  575.   .text "bo na kazde pytanie co robie "
  576.   .text "odpowiadam 'kodze' ;-p"
  577.  
  578. tekst_17:
  579.   .text " sceno - przybywam !!!!"
  580.  
  581.  
  582. kolorki:
  583.     .byte $02, $02, $00, $0a, $01, $01, $0a, $00, $02, $02, $00
  584.     .byte $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
  585.     .byte $00, $00, $00, $00
  586.  
  587.  
  588.  
  589. cykle:
  590. .byte $08, $08, $08, $01, $08, $08, $08
  591. .byte $08, $08, $08, $08, $08, $08, $0a
  592.  
  593.  
  594.  
  595.  
  596. *=$1000 "Muzyka"
  597. .import binary "Ode_to_C64.sid", $7c+2
  598.  
  599. .pc = $6000 "Logo Samar"
  600. .import c64 "logo.art"
  601.  
  602. .pc = $4800 "Font 1"
  603. .import c64 "mega_designer_3_c.64c"
  604.  
  605. .pc = $5000 "font 2"
  606. .import c64 "amigo_s.64c"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement