Mercurial > repos > ghero
view mainboot.s68 @ 15:3e2e3129a619 default tip
Re-arrange some VDP writes so that the address register gets setup properly for the FIFO-fill while still avoiding a freeze
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 08 Sep 2013 17:25:27 -0700 |
parents | 97ec271a513f |
children |
line wrap: on
line source
org $FF0000 incbin security.bin Main ;background and sprite test ButtonState equ $FFFFEFF0 ButtonStateNew equ ButtonState+2 CRAMXferSizeCmd equ $9304 StaticColors equ 12 USE_HINT equ 0 Start bsr ReadPad btst.b #7, (ButtonState).w bne LoadSLO move.l #$C00000, a4 move.l #$c00004, a5 move.l #$0, a7 lea BgFile, a0 bsr FileByNameSimple move.w #$8104, (a5) ;turn off display move.w #$8200, (a5) ;Table A = 0000 move.w #$8400, (a5) ;Table B = 0000 move.w #$857C, (a5) ;Sprite Table = F800 move.w #$8B00, (a5) ;set full screen vertical and horizontal scrolling move.w #$8D3F, (a5) ;H Scroll = FC00 move.w #$9001, (a5) ;64x32 scroll tables lea $200000, a0 move.w (a0)+, d0 ;size in words move.w (a0)+, d1 ;width in cells move.w (a0)+, d2 ;height in cells move.w d2, d7 subq #1, d0 ;adjust for 68K dbra routine move.w #$8f02, (a5) ;autoincrement = 2 move.l #$50200000, (a5);beginning of background tile area CopyTiles: move.w (a0)+, (a4) ;copy tiles to VRAM dbra d0, CopyTiles move.l #$40000000, d4 ;beginning of Plane A Name table move.l #$00800000, d5 ;delta between lines move.w #$81, d6 subq #1, d1 subq #1, d2 move.w d1, d3 WriteNamesY: move.l d4, (a5) move.w d3, d1 WriteNamesX: move.w d6, (a4) addq #1, d6 dbra d1, WriteNamesX add.l d5, d4 dbra d2, WriteNamesY move.l #$C0000000, (a5) ;setup writes to CRAM moveq #(StaticColors-1), d0 ;copy first 12 colors (static pallete) CopyColors: move.w (a0)+, (a4) dbra d0, CopyColors move.w d7, d0 lsl.w #5, d0 subq #1, d0 lea PalData(pc), a1 ;sub.l #2, a0 .copypallines: move.l (a0)+, (a1)+ dbra d0, .copypallines move.l #$60000010, (a5) ;setup writes to VSRAM move.w #$0, (a4) ;vscroll = 0 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 move.w #0, (a4) ;Plane A&B HScroll = 0; move.w #0, (a4) ; move.l #$78000003, (a5) ;clear sprite table move.l #0, (a4) move.l #0, (a4) move.w #$8114, (a5) ;turn on DMA bsr InitSprites bsr AddSprite move.w #$0, (a0) bsr LoadSpritePal bsr InitFrameBigSprite moveq #0, d3 bsr ChangeFrameBigSprite move.l #$C0180080, d5 ;setup DMA command word move.w #CRAMXferSizeCmd, (a5) ;set Transfer length move.w #$9400, (a5) move.w #$8114, d6 move.w #$8174, d7 lea VINT(pc), a1 ;setup VINT handler jsr $368 if USE_HINT lea HINT(pc), a1 ;setup HINT handler and turn on HINTs jsr $314 move.w #$8014, (a5) move.w #$8A00, (a5) ;HINT occurs on every line endif move.w #$8174, (a5) Loop: if USE_HINT bra Loop endif WaitTop: cmpi.b #$FF, 4(a5) bne.s WaitTop LineDone: move.b 4(a5), d0 WaitNextLine: cmp.b 4(a5), d0 beq WaitNextLine HINT: ;move.w d6, (a5) ;move.l d5, (a5) ;start DMA ;move.w d7, (a5) move.l d6, (a5) move.l d7, (a5) move.w #CRAMXferSizeCmd, (a5) ;set Transfer length move.w #$9400, (a5) if USE_HINT rte endif cmp.b #223, 4(a5) beq WaitTop bra LineDone VINT: move.b #1, $A12000 ;trigger interrupt on Sub CPU if USE_HINT move.w #$8144, (a5) endif bsr SpriteCopyVRAM bsr ReadPad bsr Player1Vint move.l PalData, d7 ;setup DMA source address move.w #$9500, d6 ror.l #1, d7 move.b d7, d6 move.w d6, (a5) ror.l #8, d7 move.b d7, d6 add.w #$100, d6 move.w d6,(a5) ror.l #8, d7 move.b d7, d6 add.w #$100, d6 and.b #$7F, d6 move.w d6,(a5) ;move.l d5, (a5) ;do DMA for first line move.w #CRAMXferSizeCmd, (a5) ;set Transfer length move.w #$9400, (a5) move.w #$8114, d6 ;VDP commands to turn screen on and off during HBlank swap d6 swap d5 move.w d5, d6 swap d5 move.w d5, d7 swap d7 move.w #$8174, d7 if USE_HINT move.w d7, (a5) endif rte LoadSpritePal: move.l #$C0200000, (a5) moveq #$F, d0 lea SpriteData, a0 PalLoop: move.w (a0)+, (a4) dbra d0, PalLoop rts PalAddress: dc.l 0 Player1Vint: move.b (ButtonState).w, d2 move.b (ButtonStateNew).w, d3 moveq #0, d0 move.w d0, d1 btst #5, d2 bne ScrollRight btst #7, d2 bne ScrollLeft btst #4, d3 bne IncrementFrame btst #6, d3 bne DecrementFrame btst #2, d2 beq PlayerShipNotLeft subq #1, d0 PlayerShipNotLeft: btst #3, d2 beq PlayerShipNotRight addq #1, d0 PlayerShipNotRight: btst #0, d2 beq PlayerShipNotDown subq #1, d1 PlayerShipNotDown: btst #1, d2 beq PlayerShipNotUp addq #1, d1 PlayerShipNotUp: bsr MoveBigSprite rts IncrementFrame: move.w (PlayerShipFrame), d3 addq #1, d3 move.w d3, (PlayerShipFrame) bsr ChangeFrameBigSprite rts DecrementFrame: move.w (PlayerShipFrame), d3 subq #1, d3 move.w d3, (PlayerShipFrame) bsr ChangeFrameBigSprite rts ScrollRight: move.w (ScrollValue), d0 subq #1, d0 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 move.w d0, (a4) move.w d0, (a4) move.w d0, (ScrollValue) rts ScrollLeft: move.w (ScrollValue), d0 addq #1, d0 move.l #$7C000003, (a5) ;setup writes to HScroll Table FC00 move.w d0, (a4) move.w d0, (a4) move.w d0, (ScrollValue) rts include sprites.s68 PlayerShipFrame: dc.w 0 ScrollValue: dc.w 0 ReadPad: move.b #$FF, $a10003 ;set TH for controller A move.b $a10003, d0 ;CBRLUD andi.b #$3F, d0 move.b #0, $a10003 move.b $a10003, d1 ;SA00UD andi.b #$30, d1 lsl.b #2, d1 or.b d1, d0 ;SACBRLUD not.b d0 move.b (ButtonState).w, d1 eor.b d0, d1 and.b d0, d1 move.b d0, (ButtonState).w move.b d1, (ButtonStateNew).w rts FileByNameSimple: move.b #0, $a1200e lea $a12010, a1 .copyname move.b (a0), (a1)+ tst.b (a0)+ bne .copyname bset #1, $A12003; give SUB CPU control of WordRAM .waitready tst.b $a1200f beq .waitready move.b #3, $a1200e .waitdone cmp.b #$FF, $a1200f beq .notfound tst.b $a1200f bne .waitdone bclr #1, $a12003; get control of WordRAM rts .notfound bra .notfound LoadSLO: lea LoaderFile(pc), a0 bsr FileByNameSimple move.w #(.copyEnd-.copy-1), d0 lea .copy(pc), a0 lea ($FFFF8000).w, a1 move.l a1, a2 .copycopy move.b (a0)+, (a1)+ dbra d0, .copycopy move.w #$2000, d0; more than enough for slo.bin lea $200000, a0 lea $FF0000, a1 jmp (a2) .copy move.b (a0)+, (a1)+ dbra d0, .copy jmp $FF0000 .copyEnd SpriteData: incbin bultest.bin BgFile: dc.b "LOGO.BIN",0 LoaderFile: dc.b "SLO.BIN",0 PalData: