Advertisement
yugorin

intro plus bary 16 11 2016

Nov 16th, 2016
152
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.  
  148.            
  149.             ldy #$7f    ////; $7f = %01111111
  150.             sty $dc0d   ////; wyłączamy timer CIA
  151.             sty $dd0d   ////; ; wyłączamy timer CIA
  152.             lda $dc0d   ////; kasuje wszystki przerwania CIA w kolejce
  153.             lda $dd0d   ////; kasuje wszystki przerwania CIA w kolejce
  154.          
  155.             lda #$01    ////; Set Interrupt Request Mask...
  156.             sta $d01a   ////; ...we want IRQ by Rasterbeam
  157.  
  158.             lda #<irq1   ////; wskaźnik to IRQ
  159.             ldx #>irq1
  160.             sta $314    ////; zapisz tutaj
  161.             stx $315  
  162.  
  163.             lda #$00    ////; ustawiam pierwsze przerwanie na raster 0
  164.             sta $d012
  165.             lda $d011   ////; ustawiam 9 bit z $d011 na 0            
  166.             and #$7f    ////;
  167.             sta $d011   ////;
  168.           lda #$00
  169.           jsr $1000
  170.  
  171.  
  172. //            :trybGraficzny()
  173.  //       :wybierz_index_charmem_pamieci_D018(0)
  174.   //      :wybierz_index_screen_memory_pamieci_D018(15)
  175.         :wybierz_index_banku_pamieci_VIC_DD00(1)                                        
  176.  
  177.             jsr obrazek
  178.     :ClearScreen(PamiecEkranu,$20)
  179.             cli         ////; clear interrupt disable flag
  180.          
  181.  
  182.             jsr wyswietl_text_1
  183.             jsr wyswietl_text_2
  184.  
  185.             :ClearScreen_DOL(PamiecEkranu,$20)
  186.  
  187.             jsr wyswietl_text_3
  188.  
  189.             :ClearScreen_DOL(PamiecEkranu,$20)
  190.  
  191.             jsr wyswietl_text_4
  192.             jmp *       ////; infinite loop
  193.  
  194.  
  195. ////;============================================================
  196. ////;    custom interrupt routine
  197. ////;============================================================
  198.  
  199.                
  200. irq1:  
  201.         inc $d019
  202. //        inc Ramka
  203.         lda #$37
  204.         sta $d012
  205. //        :pause #6
  206. //  :trybTekstowy()
  207.  
  208.   //      :wybierz_index_charmem_pamieci_D018(2)      
  209.         // kod poniej wykonuje się pomiędzy rastrem 34 a 80
  210.         // przerwanie jest od rastra 54 do 63
  211. ///////////////////////////////////////////////////////////////////////        
  212.  
  213.                       ldy #$00
  214. !cykl:
  215.                       ldx cykle,y
  216. !petla:
  217.                       dex
  218.                       bne !petla-
  219.  
  220.                       lda brazowe,y
  221.                       sta Ekran
  222.                       sta Ramka
  223.                       iny
  224.                       cpy #$0f
  225.                       bne !cykl-    
  226.  
  227.  
  228. ///////////////////////////////////////////////////////////////////////        
  229.  
  230.  
  231.  
  232.  
  233.  
  234.         lda #<irq2
  235.         sta $0314
  236.         lda #>irq2
  237.         sta $0315
  238.         pla
  239.         tay
  240.         pla
  241.         tax
  242.         pla
  243.   //      dec Ramka
  244.         rti
  245.  
  246.  
  247.  
  248.  
  249.  
  250. irq2:  
  251.         inc $d019
  252. //        inc Ramka
  253.         lda #$84 // pozycja środkowego rastra
  254.         sta $d012
  255. //        :pause #6
  256. //  :trybTekstowy()
  257.  
  258.   //      :wybierz_index_charmem_pamieci_D018(2)      
  259.         // kod poniej wykonuje się pomiędzy rastrem 34 a 80
  260.         // przerwanie jest od rastra 54 do 63
  261. ///////////////////////////////////////////////////////////////////////        
  262. jsr colwash
  263. jsr $1003          
  264.  
  265. ///////////////////////////////////////////////////////////////////////        
  266.  
  267.  
  268.  
  269.  
  270.  
  271.         lda #<irq3
  272.         sta $0314
  273.         lda #>irq3
  274.         sta $0315
  275.         pla
  276.         tay
  277.         pla
  278.         tax
  279.         pla
  280. //        dec Ramka
  281.         rti
  282.  
  283.  
  284.  
  285. irq3:  
  286.  
  287.         inc $d019
  288.  //       inc Ramka
  289.         lda #$9c // pozycja ostatniego rastra
  290.         sta $d012
  291. //        :pause #6
  292. //  :trybTekstowy()
  293.  
  294.   //      :wybierz_index_charmem_pamieci_D018(2)      
  295.         // kod poniej wykonuje się pomiędzy rastrem 34 a 80
  296.         // przerwanie jest od rastra 54 do 63
  297. ///////////////////////////////////////////////////////////////////////        
  298.              ldy #$00
  299. !cykl:
  300.                       ldx cykle,y
  301. !petla:
  302.                       dex
  303.                       bne !petla-
  304.  
  305.                       lda niebieskie,y
  306.                       sta Ekran
  307.                       sta Ramka
  308.                       iny
  309.                       cpy #$0f
  310.                       bne !cykl-    
  311.  
  312.  
  313. ///////////////////////////////////////////////////////////////////////        
  314.  
  315.  
  316.  
  317.  
  318.  
  319.         lda #<irq1
  320.         sta $0314
  321.         lda #>irq1
  322.         sta $0315
  323.         pla
  324.         tay
  325.         pla
  326.         tax
  327.         pla
  328. //        dec Ramka
  329.         rti
  330.  
  331.  
  332.  
  333.  
  334. ///////////////////////////////////////////////////////////////// wyświetyla tekst na górnym przerwaniu
  335. wyswietl_text_1:
  336.     ldx #$00
  337.  
  338. !petla:
  339.     lda teksty,x
  340.     sta PamiecEkranu,x
  341.     jsr opoznienie
  342.     cpx #119
  343.     beq powrot
  344.     inx
  345.     bne !petla-
  346.  
  347. powrot:  
  348.     rts
  349. ///////////////////////////////////////////////////////////////// wyświetyla tekst na górnym przerwaniu
  350.  
  351.  
  352.  
  353.  
  354. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu
  355. wyswietl_text_2:
  356.     ldx #$00
  357. !petla:
  358.     lda tekst_2,x
  359.     sta PamiecEkranu+640,x
  360.     jsr opoznienie
  361.     cpx #200
  362.     beq !powrot+
  363.     inx
  364.     bne !petla-
  365. !powrot:
  366.     rts
  367. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu
  368.  
  369.  
  370.  
  371. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu - zmiana ekranu
  372. wyswietl_text_3:
  373.     ldx #$00
  374. !petla:
  375.     lda tekst_8,x
  376.     sta PamiecEkranu+845,x
  377.     jsr opoznienie
  378.     cpx #31
  379.     beq !powrot+
  380.     inx
  381.     bne !petla-
  382. !powrot:
  383.     rts
  384. ///////////////////////////////////////////////////////////////// wyświetyla tekst na dolnym przerwaniu - zmiana ekranu
  385.  
  386.  
  387.  
  388. wyswietl_text_4:
  389.     ldx #$00
  390. !petla:
  391.     lda tekst_10,x
  392.     sta PamiecEkranu+640,x
  393.     jsr opoznienie
  394.     cpx #239
  395.     beq !powrot+
  396.     inx
  397.     bne !petla-
  398. !powrot:
  399.     rts
  400.  
  401.  
  402. wyswietl_text_5:
  403.     ldx #$00
  404. !petla:
  405.     lda tekst_15,x
  406.     sta PamiecEkranu+642,x
  407.     jsr opoznienie
  408.     cpx #255
  409.     beq !powrot+
  410.     inx
  411.     bne !petla-
  412. !powrot:
  413.     rts
  414.  
  415. wyswietl_text_6:
  416.     ldx #$00
  417. !petla:
  418.     lda tekst_16,x
  419.     sta PamiecEkranu+880,x
  420.     jsr opoznienie
  421.     cpx #51
  422.     beq !powrot+
  423.     inx
  424.     bne !petla-
  425. !powrot:
  426.     rts
  427.  
  428.  
  429. wyswietl_text_7:
  430.     ldx #$00
  431. !petla:
  432.     lda tekst_17,x
  433.     sta PamiecEkranu+851,x
  434.     jsr opoznienie
  435.     cpx #22
  436.     beq !powrot+
  437.     inx
  438.     bne !petla-
  439. !powrot:
  440.     rts
  441.  
  442. opoznienie:
  443.       txa
  444.       ldx #$00  
  445. petla1:
  446.       ldy #$00
  447. petla2:
  448.       iny
  449.       cpy #$40
  450.       bne petla2
  451.       inx
  452.       cpx #$90
  453.       bne petla1
  454.       tax
  455.       rts
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.        
  466. colwash:   ldx #$27        //; load x-register with #$27 to work through 0-39 iterations
  467.           lda color+$28   //; init accumulator with the last color from first color table
  468.  
  469. cycle1:    ldy color-1,x   //; remember the current color in color table in this iteration
  470.           sta color-1,x   //; overwrite that location with color from accumulator
  471.           sta $d800,x     //; put it into Color Ram into column x
  472.           tya             //; transfer our remembered color back to accumulator
  473.           dex             //; decrement x-register to go to next iteration
  474.           bne cycle1      //; repeat if there are iterations left
  475.           sta color+$28   //; otherwise store te last color from accu into color table
  476.           sta $d800       //; ... and into Color Ram
  477.                            
  478. colwash2:  ldx #$00        //; load x-register with #$00
  479.           lda color2+$28  //; load the last color from the second color table
  480.  
  481. cycle2:    ldy color2,x    //; remember color at currently looked color2 table location
  482.           sta color2,x    //; overwrite location with color from accumulator
  483.           sta $d850,x     //; ... and write it to Color Ram
  484.           tya             //; transfer our remembered color back to accumulator
  485.           inx             //; increment x-register to go to next iteraton
  486.           cpx #$28        //; have we gone through 39 iterations yet?
  487.           bne cycle2      //; if no, repeat
  488.           sta color2+$28  //; if yes, store the final color from accu into color2 table
  489.           sta $d850+$27   //; and write it into Color Ram
  490.  
  491.           rts             //; return from subroutine
  492.  
  493.  
  494. color:       .byte $09,$09,$02,$02,$08
  495.              .byte $08,$0a,$0a,$0f,$0f
  496.              .byte $07,$07,$01,$01,$01
  497.              .byte $01,$01,$01,$01,$01
  498.              .byte $01,$01,$01,$01,$01
  499.              .byte $01,$01,$01,$07,$07
  500.              .byte $0f,$0f,$0a,$0a,$08
  501.              .byte $08,$02,$02,$09,$09
  502.  
  503. color2:       .byte $09,$09,$02,$02,$08
  504.              .byte $08,$0a,$0a,$0f,$0f
  505.              .byte $07,$07,$01,$01,$01
  506.              .byte $01,$01,$01,$01,$01
  507.              .byte $01,$01,$01,$01,$01
  508.              .byte $01,$01,$01,$07,$07
  509.              .byte $0f,$0f,$0a,$0a,$08
  510.              .byte $08,$02,$02,$09,$09
  511.  
  512.  
  513.  
  514. obrazek:
  515.  
  516.    ldx #$00
  517.    
  518. laduj_obrazek:
  519. //    lda $3f40+$4000,x
  520. //    sta PamiecEkranu,x
  521.     lda $3f40+$4000+256,x
  522.     sta PamiecEkranu+256,x
  523.     lda $3f40+$4000+300,x
  524.     sta PamiecEkranu+300,x
  525. //    lda $3f40+$4000+768,x
  526. //    sta PamiecEkranu+768,x
  527.     dex
  528.     bne laduj_obrazek
  529.     rts
  530.  
  531.  
  532. opoznienie2:
  533.         txa
  534.             ldx #$00   
  535.  
  536. petla1_2:
  537.             ldy #$00
  538.  
  539. petla2_2:
  540.             iny
  541.             cpy #$50
  542.             bne petla2_2
  543.             inx
  544.             cpx #$90
  545.             bne petla1_2
  546.             tax
  547.             rts
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555. opoznienie3:
  556.         txa
  557.             ldx #$00   
  558.  
  559. petla4_1:
  560.             ldy #$00
  561.  
  562. petla4_2:
  563.             iny
  564.             cpy #$ff
  565.             bne petla4_2
  566.             inx
  567.             cpx #$ff
  568.             bne petla4_1
  569.             tax
  570.             rts
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578. teksty:
  579.         .text "     yugorin of samar productions       "
  580.     .text "     prezentuje pierwsze wypociny       "
  581.     .text "    po  30 latach bycia w niebycie      "
  582.  
  583.  
  584.  
  585.  
  586.  
  587. tekst_2:
  588.         .text "nie umiem jeszcze zrobic scrolla, ale to"
  589.         .text "kwestia czasu. bardzo chcialem zrobic   "
  590.         .text "pierwsze 'cos', zeby moc powiedziec     "
  591.         .text "wszystkim, ze po 30 latach jestem tu,   "
  592.         .text "gdzie przerwalem jako dziecko.          "
  593.  
  594. tekst_8:
  595.         .text " nigdy nie zrobilem scrolla :-)     "
  596.  
  597. tekst_10:
  598.  
  599.   .text "dziekuje dkt, isildurowi i slajerkowi za"
  600.   .text "wiare we mnie. calemu samarowi za przy- "
  601.   .text "jecie, jammerowi za opierdol na start za"
  602.   .text "dropboxa. wielkie dzieki mlodszemu bratu"
  603.   .text "programiscie (fucking genius)!! za wiare"
  604.   .text "wsparcie i cierpliwosc do mnie.         "
  605.  
  606.  
  607.  
  608.   tekst_15:
  609.  
  610.   .text " to, ze skubany nie zna asm"
  611.   .text " a tlumaczy mi co robie zle"
  612.   .text " sprawia,ze jestem dumny"
  613.   .text " z niego jak nikt na swiecie."
  614.   .text "namawiam go na kodzenie w asm "
  615.   .text "na c64. zobaczymy co z tego wyjdzie."
  616.   .text "na koniec dziekuje asi i biance "
  617.   .text "za to, ze jeszcze nie zwariowaly "
  618.  
  619.   tekst_16:
  620.   .text "bo na kazde pytanie co robie "
  621.   .text "odpowiadam 'kodze' ;-p"
  622.  
  623. tekst_17:
  624.   .text " sceno - przybywam !!!!"
  625.  
  626.  
  627. niebieskie:
  628.     .byte $06,$06,$0e,$0e,$03,$03,$01,$01,$03,$03,$0e,$0e,$06,$06,$00
  629.  
  630. brazowe:
  631.  
  632.     .byte $02,$02,$08,$08,$0a,$0a,$01,$01,$0a,$0a,$08,$08,$02,$02,$00
  633. /// raster $33 bad line - potem 7 linii OK i 8 znów bad lines ($3b)
  634.  
  635. cykle:
  636. .byte $01, $08, $08, $08, $08, $08, $08, $08
  637. .byte $01, $08, $08, $08, $08, $08, $07
  638.  
  639.  
  640.  
  641.  
  642.  
  643. *=$1000 "Muzyka"
  644. .import binary "Ode_to_C64.sid", $7c+2
  645.  
  646. .pc = $6000 "Logo Samar"
  647. .import c64 "logo.art"
  648.  
  649. .pc = $4800 "Font 1"
  650. .import c64 "mega_designer_3_c.64c"
  651.  
  652. .pc = $5000 "font 2"
  653. .import c64 "amigo_s.64c"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement