home *** CD-ROM | disk | FTP | other *** search
/ TCE Demo 2 / TCE_DEMO_CD2.iso / demo_cd_.2 / mags / dba / dba_13.arj / dba-13 / GOODIES / H_SCROLL.S < prev    next >
Text File  |  1987-04-22  |  13KB  |  316 lines

  1.  
  2. * Example program on how to use my new vertical hardware scroll technique.
  3. * Written for DBA Magazine in May 1993. Hardwarescroll developed at
  4. * the end of summer 1992.
  5. * Code, Hardwarescroll development and Graphics by
  6. * Robert from The Atari Boys.
  7. * Written with Turbo Assembler V1.7.6 (It's verry fast and easy to use.)
  8. * Music from the game Circus Attractions.
  9. * I think it is converted by Mad Max.
  10. * Read the article on DBA Magazine for more information !!!
  11.  
  12.                 pea     0               ; switch to supervisor mode
  13.                 move.w  #$20,-(SP)
  14.                 trap    #1
  15.                 addq.l  #6,SP           ; repair stack pointer
  16.                 move.l  D0,oldstack
  17.  
  18.                 pea     text(PC)        ; print some text
  19.                 move.w  #9,-(SP)
  20.                 trap    #1
  21.                 addq.l  #6,SP
  22.  
  23. waitkey:        cmpi.b  #$39+128,$FFFFFC02.w ; wait for release of space
  24.                 bne.s   waitkey
  25.  
  26.                 move.b  $FFFF8260.w,oldres ; store old resolution
  27.  
  28.                 move.w  #$25,-(SP)      ; wait for vbi
  29.                 trap    #14
  30.                 addq.l  #2,SP           ; repair stack pointer
  31.  
  32.                 move.b  #0,$FFFF8260.w  ; switch to low resolution
  33. * if you don't switch after a vbi, the screen can get shifted
  34.  
  35.                 move    #$2700,SR       ; interupts off
  36.  
  37.                 move.l  $70.w,oldvbi    ; store old vbi vector
  38.                 move.l  $0120.w,oldtimerb ; store old timer b vector
  39.  
  40.                 move.b  $FFFFFA07.w,olda07 ; store interupt enable registers
  41.                 move.b  $FFFFFA09.w,olda09
  42.  
  43.                 move.b  $FFFFFA13.w,olda13 ; store old interupt mask
  44.                 move.b  $FFFFFA1B.w,olda1b ; store timer b control register
  45.                 move.b  $FFFA17,olda17  ; store old EOI mode
  46.                 move.b  $FFFF8201.w,old8201 ; store video base register high
  47.                 move.b  $FFFF8203.w,old8203 ; store video base register mid
  48.  
  49.                 move.b  $FFFF820A.w,old820a ; store old sync mode register
  50.  
  51.                 movem.l $FFFF8240.w,D0-D7 ; store old color palette
  52.                 movem.l D0-D7,oldcolor
  53.  
  54.                 move.l  #screen,D0      ; new screen adress
  55.                 andi.l  #$FFFFFF00,D0   ; screen on page boundary
  56.  
  57.  
  58.                 move.l  D0,screenadress ; store screen adress
  59.                 add.l   #8*160,D0
  60.                 move.l  D0,store
  61.  
  62.                 moveq   #1,D0           ; init music
  63.                 bsr     mus
  64.  
  65.                 move.b  screenadress+1,$FFFF8201.w ; write new screen adress
  66.                 move.b  screenadress+2,$FFFF8203.w
  67.  
  68.                 movem.l color(PC),D0-D7 ; new color palette
  69.                 movem.l D0-D7,$FFFF8240.w
  70.  
  71.                 movea.l screenadress,A0 ; copy logo all over the screen
  72.                 lea     logo(PC),A1     ; there must be something on the screen
  73.  
  74.  
  75.                 move.w  #13-1,D2        ; 13 rows = 208 lines (for 200 lines )
  76. copy3:          move.w  #20-1,D1        ; 20 koloms           (the routine   )
  77. copy2:          move.w  #16-1,D0        ; 16 lines            (would be more )
  78. copy1:          move.w  (A1),(A0)       ; plot plane 0        (complicated   )
  79.                 move.w  32(A1),2(A0)    ; plot plane 1
  80.                 move.w  64(A1),4(A0)    ; plot plane 2
  81.                 move.w  96(A1),6(A0)    ; plot plane 3
  82.                 adda.l  #160,A0         ; next line
  83.                 adda.l  #2,A1
  84.                 dbra    D0,copy1
  85.                 suba.l  #32,A1          ; next kolom
  86.                 suba.l  #2552,A0
  87.                 dbra    D1,copy2
  88.                 adda.l  #2400,A0        ; next row
  89.                 dbra    D2,copy3
  90.  
  91.                 clr.b   $FFFFFA1B.w     ; timer b off
  92.  
  93.                 bclr    #3,$FFFFFA17.w  ; auto end of interupt
  94.                 move.l  #vbi,$70.w      ; write new vbi vector
  95.                 move.l  #timerb,$0120.w ; write new timer b vector
  96.  
  97.                 move.b  #1,$FFFFFA07.w  ; interupts off exept timer b, else
  98.                 clr.b   $FFFFFA09.w     ; the mouse causes trash.
  99.  
  100.                 move.b  #1,$FFFFFA13.w  ; interupts masked exept timer b
  101.  
  102.                 move    #$2300,SR       ; interupts on
  103.  
  104. comp:           move.b  $FFFFFC02.w,D0  ; load key in d0
  105.  
  106.                 cmpi.b  #$39,D0         ; is it space ?
  107.                 beq.s   the_end         ; jump if space
  108.                 cmpi.b  #72,D0          ; arrow up pressed ?
  109.                 beq.s   up              ; jump if arrow up
  110.                 cmpi.b  #80,D0          ; arrow down pressed ?
  111.                 bne.s   comp            ; jump if arrow down
  112. down:           cmpi.w  #6,addje+2      ; is it 6 already ?
  113.                 beq.s   nokey           ; exit if 6
  114.                 addi.w  #1,addje+2      ; shit !! some self modifying code to
  115.                 addi.w  #1,subje+2      ; modify self modifying code. (????)
  116.  
  117. nokey:          cmpi.b  #80+128,$FFFFFC02.w ; arrow down released ??
  118.                 bne.s   nokey           ; jump if it isn't
  119.                 bra.s   comp            ; loop again
  120.  
  121. up:             cmpi.w  #-6,addje+2     ; is it -6 already
  122.                 beq.s   nokey2          ; exit if it is -6
  123.                 subi.w  #1,addje+2      ; shit ! more self modifying code
  124.                 subi.w  #1,subje+2      ; to modify self modifying code
  125.  
  126. nokey2:         cmpi.b  #72+128,$FFFFFC02.w ; is arrow up released ?
  127.                 bne.s   nokey2          ; jump if it isn't
  128.                 bra.s   comp            ; loop again
  129.  
  130. the_end:        move    #$2700,SR       ; interupts off
  131.  
  132.                 moveq   #0,D0           ; music off
  133.                 bsr     mus
  134.  
  135.                 movem.l oldcolor,D0-D7  ; restore old colors
  136.                 movem.l D0-D7,$FFFF8240.w
  137.  
  138.                 move.l  oldvbi,$70.w    ; restore old vbi vector
  139.                 move.l  oldtimerb,$0120.w ; restore old timer b vector
  140.                 move.b  olda17,$FFFFFA17.w ; restore old EOI mode
  141.  
  142.                 move.b  olda07,$FFFFFA07.w ; restore interupt enable registers
  143.                 move.b  olda09,$FFFFFA09.w
  144.  
  145.                 move.b  olda13,$FFFFFA13.w ; restore interupt mask register
  146.  
  147.                 move.b  olda1b,$FFFFFA1B.w ; restore timer b mode register
  148.  
  149.                 move.b  old8201,$FFFF8201.w ; restore old screen adress
  150.                 move.b  old8203,$FFFF8203.w
  151.  
  152.                 move.b  old820a,$FFFF820A.w ; restore sync mode register
  153.  
  154.                 move    #$2300,SR       ; interupt on
  155.  
  156.                 move.w  #$25,-(SP)      ; wait for vbi
  157.                 trap    #1
  158.                 addq.l  #2,SP           ; restore stack pointer
  159.  
  160.                 move.b  oldres,$FFFF8260.w ; restore old resolution
  161.  
  162.                 move.l  oldstack,-(SP)  ; switch back to user mode
  163.                 move.w  #$20,-(SP)
  164.                 trap    #1
  165.                 addq.l  #6,SP           ; restore stack pointer
  166.  
  167.                 clr.w   -(SP)           ; end of program
  168.                 trap    #1
  169.  
  170. vbi:            movem.l D0-A6,-(SP)     ; store registers
  171.  
  172.                 move.w  #52,D0          ; wait
  173. wait:           dbra    D0,wait
  174.  
  175. lines:          move.w  #0,D0           ; no. lines to be scrolled
  176.                 bra     scroll
  177.  
  178. scroll2:        move.b  #2,$FFFF8260.w  ; switch to 70 Hz (hi res)
  179.                 REPT 7          ; wait 7*4 clock cycles
  180.                 nop
  181.                 ENDR
  182.                 move.b  #0,$FFFF8260.w  ; switch back to low
  183.                 REPT 110        ; wait till next line
  184.                 nop
  185.                 ENDR
  186. scroll:         dbra    D0,scroll2      ; another line ?
  187.  
  188.                 move.b  #0,$FFFFFA1B.w  ; timer b off
  189. raster:         move.b  #8,$FFFFFA21.w  ; interupt after (8-no. lines) lines
  190.                 move.b  #8,$FFFFFA1B.w  ; timer b on
  191.  
  192. * Rasters are needed to make a visible window of the screen. Else you see
  193. * the screen flipping. Change 8 into 0 in the instruction above and you
  194. * see what I mean.
  195.  
  196. subje:          subi.w  #1,raster+2     ; shit !! some self modifying code to
  197. addje:          addi.w  #1,lines+2      ; change no. lines to be scrolled
  198.                 cmpi.w  #-1,lines+2     ; is lines greater than -1
  199.                 bgt.s   not             ; jump if yes
  200.                 addi.w  #8,lines+2      ; add 8 lines ; scroll up
  201.                 subi.w  #8,raster+2     ; sub 8 raster lines
  202.                 bra.s   changescreen    ; change screen
  203. not:            cmpi.w  #8,lines+2      ; is lines less than 8
  204.                 blo.s   einde           ; jump if yes
  205.                 subi.w  #8,lines+2      ; sub 8 lines ; scroll down
  206.                 addi.w  #8,raster+2     ; add 8 raster lines
  207. changescreen:   move.l  store,-(SP)     ; scroll 8 lines up or down
  208.                 move.l  screenadress,store
  209.                 move.l  (SP)+,screenadress
  210.                 move.b  screenadress+1,$FFFF8201.w ; write new screen
  211.                 move.b  screenadress+2,$FFFF8203.w
  212.  
  213. einde:
  214.  
  215.                 bsr     mus+8           ; play music
  216.  
  217.                 movem.l (SP)+,D0-A6     ; restore registers
  218.                 rte                     ; end of interupt
  219.  
  220.  
  221. timerb:
  222.                 move.l  D0,-(SP)        ; store d0
  223.                 clr.b   $FFFFFA1B.w     ; timer b off
  224.                 move.b  #191,$FFFFFA21.w ; interupt after 192 lines
  225.                 move.l  #timerb2,$0120.w ; new timer b vector
  226.                 move.b  #8,$FFFFFA1B.w  ; timer b on
  227.  
  228.                 move.w  #27,D0          ; wait till end of line
  229. wait2:          dbra    D0,wait2        ; for invisible color change
  230.  
  231.                 move.l  #$010002,$FFFF8244.w ; make screen visible
  232.                 move.l  #$030004,$FFFF8248.w
  233.                 move.l  #$050006,$FFFF824C.w
  234.                 move.l  #$070770,$FFFF8250.w
  235.                 move.l  #$06600550,$FFFF8254.w
  236.                 move.l  #$04400330,$FFFF8258.w
  237.                 move.l  #$02200110,$FFFF825C.w
  238.  
  239.                 move.l  (SP)+,D0        ; restore d0
  240.  
  241.                 rte                     ; end of interupt
  242. timerb2:
  243.                 move.l  D0,-(SP)        ; store d0
  244.                 clr.b   $FFFFFA1B.w     ; timer b off
  245.                 move.l  #timerb,$0120.w ; new timer b vector
  246.  
  247.                 move.w  #30,D0          ; wait till end of line
  248. wait3:          dbra    D0,wait3        ; for invisible color change
  249.  
  250.  
  251.                 clr.l   $FFFF8244.w     ; switch all colors to black
  252.                 clr.l   $FFFF8248.w     ; so you can't see the screen bounceing
  253.                 clr.l   $FFFF824C.w
  254.                 clr.l   $FFFF8250.w
  255.                 clr.l   $FFFF8254.w
  256.                 clr.l   $FFFF8258.w
  257.                 clr.l   $FFFF825C.w
  258.                 move.l  (SP)+,D0        ; restore d0
  259.  
  260.                 rte                     ; end of interupt
  261.  
  262.  
  263.  
  264.                 SECTION DATA
  265.  
  266. logo:           DC.W $AA55,$2A54,$C203,$7EFC,$984F,$6270,$9E4F,$7C30 ; plane 1
  267.                 DC.W $3E30,$F84F,$0670,$904F,$7E70,$C247,$2A54,$AA55
  268.  
  269.                 DC.W $6666,$E667,$FEFF,$00,$40,$FE7F,$FE7F,$00 ; plane 2
  270.                 DC.W $00,$FE7F,$FE7F,$0840,$40,$FE77,$E667,$6666
  271.  
  272.                 DC.W $1E78,$1E78,$3EFC,$FEFF,$FE7F,$9E4F,$9E4F,0 ; plane 3
  273.                 DC.W $00,$F84F,$F84F,$FE7F,$FE7F,$3E78,$1E78,$1E78
  274.  
  275.                 DC.W $0180,$0180,$3DFC,$7FFC,$67B0,$61B0,$61B0,$FFFF ; plane 4
  276.                 DC.W $FFFF,$07B0,$07B0,$67B0,$7FB0,$3DB0,$0180,$0180
  277.  
  278. color:          DC.W $00,$00,$01,$02,$03,$04,$05,$06,$07
  279.                 DC.W $0770,$0660,$0550,$0440,$0330,$0220,$0111
  280.  
  281. mus:            incbin 'A:\GFA_ASM\*.MUS'
  282.                 EVEN
  283.  
  284. text:
  285.                 DC.B 27,'EExample program which shows my new ',10,13
  286.                 DC.B 'vertical hardware scroll technique.',10,13
  287.                 DC.B 'Written by Robert from The Atari Boys',10,13
  288.                 DC.B 'for DBA magazine.',10,13
  289.                 DC.B 'Press arrow up and down to change speed',10,13
  290.                 DC.B 'and direction.',10,13,10,13
  291.                 DC.B 'Press space to continue',10,13
  292.                 DC.B 0
  293.  
  294.                 EVEN
  295.  
  296.                 SECTION BSS
  297.  
  298.                 DS.B 256        ; extra space for screen boundary
  299. screen:         DS.B 32000+8*160 ; screen space +8 extra lines (16*13=208)
  300. screenadress:   DS.L 1
  301. oldcolor:       DS.W 16
  302. store:          DS.L 1
  303. oldstack:       DS.L 1
  304. oldvbi:         DS.L 1
  305. oldtimerb:      DS.L 1
  306. olda07:         DS.B 1
  307. olda09:         DS.B 1
  308. olda13:         DS.B 1
  309. olda1b:         DS.B 1
  310. olda17:         DS.B 1
  311. oldres:         DS.B 1
  312. old8201:        DS.B 1
  313. old8203:        DS.B 1
  314. old820a:        DS.B 1
  315.                 END
  316.