Advertisement
BlueBear

a500 demo framework

Jun 18th, 2017
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     INCLUDE "include/PhotonsMiniWrapper.s"
  3.  
  4. ********** Demo **********  ;Demo-specific non-startup code below.
  5.  
  6. w   =320                    ;screen width, height, depth
  7. h   =256                    ;180 for 16:9 friendly
  8. bpls    =3             
  9. bpl =w/16*2                 ;byte-width of 1 bitplane line
  10. bwid    =bpls*bpl           ;byte-width of 1 pixel line (all bpls)
  11.  
  12.  
  13. ;modulo operator
  14. ;d0 dividend
  15. ;d1 divisor
  16. ;d2 remainder
  17. modulo:
  18.     clr.l d2
  19.     move.w d0, d2
  20.     divu d1, d2
  21.     swap d2
  22.     rts
  23.  
  24. Demo:                       ;a4=VBR, a6=Custom Registers Base addr
  25.     *--- init ---*
  26.     move.l #VBint,$6c(a4)   ;Set our new VERTB vector,
  27.     move.w #$c020,$9a(a6)   ;and enable the interrupt.
  28.     move.w #$87c0,$96(a6)   ;Enable Blitter, Bitplane, Copper DMA
  29.  
  30.     lea Screen,a0           ;pointer start addr
  31.     moveq #bpl,d0           ;pointer addr increment
  32.     lea BplPtrs+2,a1        ;start position to poke in copper
  33.     moveq #bpls-1,d1        ;pointer count-1
  34.     bsr.s PokePtrs          ;poke bitplane ptrs into copper list.
  35.  
  36.     move.l #Copper,$80(a6)  ;Now set our initalized copper.
  37.     *--- main loop ---*
  38. MainLoop:
  39.     ;framecounter
  40.     move.l frame,d1
  41.     addq.l #1,d1
  42.     move.l d1,frame
  43.  
  44.     lea Screen,a1           ;Then, the screen
  45.     bsr.s ClearScreen       ;clear, Yoda pls.
  46.     bsr.s WaitBlitter       ;Wait out blit: we plot to same area
  47.  
  48.     lea Screen,a1           ;and to the destination screen
  49.    
  50.     move.l xpos, d0
  51.     movem.l d0,-(sp)        ;push to stack
  52.  
  53.     move.l #319, d7         ;loop iterations
  54.     .loop1:
  55.         move.w xpos, d1
  56.         move.w #10, d2
  57.         move.w #2, d3
  58.         bsr.s PutPixel
  59.  
  60.         move.w xpos,d0
  61.         addq.w #1,d0
  62.         move.w d0,xpos
  63.        
  64.         subq.w #1,d7
  65.         bne .loop1
  66.    
  67.     movem.l (sp)+,d0        ;pop from stack
  68.     move.l d0, xpos
  69.  
  70.     move.w #$111,$180(a6)   ;(Optional: shows rastertime left)
  71.  
  72.     move.w #$12c,d0         ;No buffering, so wait until raster
  73.     bsr.w WaitRaster        ;is below the Display Window.
  74.  
  75.     btst #6,$bfe001         ;Left mouse button not pressed?
  76.     bne.s MainLoop          ;then loop
  77.     *--- exit ---*
  78.     rts                     ;else exit demo
  79.  
  80. ********** Demo Routines **********
  81.  
  82. PokePtrs:                   ;Generic, poke ptrs into copper list
  83. .bpll:  move.l a0,d2
  84.     swap d2
  85.     move.w d2,(a1)          ;high word of address
  86.     move.w a0,4(a1)         ;low word of address
  87.     addq.w #8,a1            ;skip two copper instructions
  88.     add.l d0,a0             ;next ptr
  89.     dbf d1,.bpll
  90.     rts
  91.  
  92. ClearScreen:                ;a1=screen destination address to clear
  93.     bsr.w WaitBlitter
  94.     clr.w $66(a6)           ;destination modulo
  95.     move.l #$01000000,$40(a6)   ;set operation type in BLTCON0/1
  96.     move.l a1,$54(a6)       ;destination address
  97.     move.w #h*bpls*64+bpl/2,$58(a6) ;blitter operation size: 768x20 words
  98.     rts
  99.  
  100. ;d1=x, d2=y, d3=color, a1=screen
  101. PutPixel:                  
  102.     movem.l d1-d5/a1,-(sp)
  103.  
  104.     muls #bwid,d2           ;Address offset for line
  105.     move.w d1,d4            ;left-to-right x position,
  106.     not.w d4            ;to bit 7-0 (other bits unused by bset)
  107.     asr.w #3,d1         ;Byte offset for x position
  108.     ext.l d1            ;(big offsets for large screens?)
  109.     add.l d1,d2         ;added to final address offset.
  110.  
  111.     moveq #bpls-1,d5        ;Loop through bitplanes:
  112. .l:
  113.     ror.b #1,d3         ;color bit for bitplane set?
  114.     bpl.s .noset
  115.     bset d4,(a1,d2.l)       ;then set bit.
  116. .noset:
  117.     lea bpl(a1),a1          ;go to next bitplane
  118.     dbf d5,.l
  119.     movem.l (sp)+,d1-d5/a1
  120.     rts
  121.  
  122. VBint:                  ;Blank template VERTB interrupt
  123.     movem.l d0/a6,-(sp)     ;Save used registers, could have been
  124.     lea $dff000,a6          ;modified, so set custom base again.
  125.     btst #5,$1f(a6)         ;My level 3 interrupt?
  126.     beq.s .notvb            ;if not, skip
  127.     *--- do stuff here ---*
  128.     moveq #$20,d0           ;VB interrupt bit
  129.     move.w d0,$9c(a6)       ;clear, Yoda pls.
  130.     move.w d0,$9c(a6)       ;twice, Yoda pls. (A4000 fix)
  131. .notvb: movem.l (sp)+,d0/a6
  132.     rte
  133.  
  134. *******************************************************************************
  135.     SECTION ChipData,DATA_C     ;declared data that must be in chipmem
  136. *******************************************************************************
  137.  
  138. Copper:
  139.     dc.w $1fc,0         ;Slow fetch mode, remove if AGA demo.
  140.     dc.w $8e,$2c81          ;Standard display window top, left
  141.     dc.w $90,$2cc1          ;and bottom, right.
  142.     dc.w $92,$38            ;Standard bitplane dma fetch start
  143.     dc.w $94,$d0            ;and stop for standard screen.
  144.  
  145.     dc.w $108,bwid-bpl      ;modulos
  146.     dc.w $10a,bwid-bpl
  147.  
  148.     dc.w $102,0         ;Scroll register (and playfield pri)
  149.  
  150. Palette:                ;Palette from COLOR00 to COLOR07
  151.     dc.w $180,$000          ;black (red,green,blue=0,0,0)
  152.     dc.w $182,$00f          ;blue
  153.     dc.w $184,$0f0          ;green
  154.     dc.w $186,$0ff          ;cyan (=green+blue)
  155.     dc.w $188,$f00          ;red
  156.     dc.w $18a,$f0f          ;magenta (=red+blue)
  157.     dc.w $18c,$ff0          ;yellow (=red+green)
  158.     dc.w $18e,$fff          ;white (red,green,blue=15,15,15)
  159.  
  160. BplPtrs:
  161.     dc.w $e0,0          ;set high
  162.     dc.w $e2,0          ;and low word of bitplane ptr 1
  163.     dc.w $e4,0          ;same for bitplane 2
  164.     dc.w $e6,0
  165.     dc.w $e8,0          ;and bitplane 3
  166.     dc.w $ea,0
  167.     dc.w $100,bpls*$1000+$200   ;enable bitplanes
  168.  
  169.     dc.w $ffdf,$fffe        ;allow VPOS>$ff
  170.     dc.w $ffff,$fffe        ;magic value, signals end of copperlist
  171.  
  172. ;sine table
  173. sin32_15:
  174.     dc.b 8,9,10,12,13,14,14,15,15,15,14,14,13,12,10,9,8,6,5,3,2,1,1,0,0,0,1,1,2,3,5,6
  175. frame:        
  176.     dc.l 0
  177.  
  178. xpos:        
  179.     dc.l 0
  180. ypos:        
  181.     dc.l 0
  182.  
  183. *******************************************************************************
  184.     SECTION ChipBuffers,BSS_C   ;BSS doesn't count toward exe size
  185. *******************************************************************************
  186.  
  187. Screen: ds.b h*bwid         ;Define storage to reserve for screen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement