Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | Jaguar support code
- | by Chilly Willy
- #include <jaguar.h>
- | First equates control the bitmap size and depth, and screen mode
- .equ BMP_WIDTH, 320 /* Width in Pixels */
- .equ BMP_HEIGHT, 224 /* Height in Pixels */
- .equ BMP_DEPTH, O_DEPTH16 /* Depth of Bitmap */
- .equ PPP, 4 /* Pixels per Phrase (16-bit) */
- .equ SCR_MODE, RGB16 /* Video Mode (CRY16, RGB16, or RGB24) */
- .equ PIX_WIDTH, PWIDTH4 /* Pixel width of video mode */
- .equ PIX_SHIFT, 2 /* 2^PIX_SHIFT == PIX_WIDTH */
- .equ BMP_PHRASES, (BMP_WIDTH/PPP) /* Width in Phrases */
- .equ BMP_LINES, (BMP_HEIGHT*2) /* Height in Half Scanlines */
- .equ BITMAP_OFF, (2*8) /* Two Phrases */
- .equ LISTSIZE, 5 /* List length (in phrases) */
- .text
- | Jaguar startup at 0x2000 (CART) or 0x4000 (BJL)
- .global _start
- _start:
- move #0x2700,sr /* disable interrupts */
- move.l #0x70007,G_END /* big-endian mode */
- move.l #0x70007,D_END
- move.w #0xFFFF,VI /* disable video interrupts */
- | Clear BSS
- lea __bss_start,a0
- lea __bss_end,a1
- moveq #0,d0
- 1:
- move.l d0,(a0)+
- cmpa.l a0,a1
- bhi.b 1b
- .ifdef CART_BUILD
- | Copy code and initialized variables from ROM to RAM
- lea _code_start(pc),a0
- lea _code_start,a1
- move.l #__code_size+__data_size,d0
- lsr.l #2,d0
- 2:
- move.l (a0)+,(a1)+
- subq.l #1,d0
- bne.b 2b
- jmp _code_start
- .align 2
- _code_start:
- .endif
- lea INITSTACK,a0
- movea.l a0,sp /* set stack pointer to top of main DRAM */
- link.w a6,#-8 /* set up initial stack frame */
- jsr init_hardware /* initialize the console hardware */
- jsr __INIT_SECTION__ /* do all program initializers */
- jsr main /* call program main() */
- jsr __FINI_SECTION__ /* do all program finishers */
- jmp _start+0x800000
- | Procedure: InitVBint
- | Install our vertical blank handler and enable interrupts
- InitVBint:
- move.l #UpdateList,LEVEL0 /* Install 68K LEVEL0 handler */
- move.w a_vde,d0 /* Must be ODD */
- ori.w #1,d0
- move.w d0,VI
- move.w #C_VIDENA,INT1 /* Enable video interrupts */
- move.w sr,d0
- andi.w #0xF8FF,d0 /* Lower 68k IPL to allow */
- move.w d0,sr /* interrupts */
- rts
- | Procedure: InitVideo (same as in vidinit.s)
- | Build values for hdb, hde, vdb, and vde and store them.
- InitVideo:
- move.w CONFIG,d0 /* Also is joystick register */
- andi.w #VIDTYPE,d0 /* 0 = PAL, 1 = NTSC */
- beq.b palvals
- move.w #NTSC_HMID,d2
- move.w #NTSC_WIDTH,d0
- move.w #NTSC_VMID,d6
- move.w #NTSC_HEIGHT,d4
- bra.b calc_vals
- palvals:
- move.w #PAL_HMID,d2
- move.w #PAL_WIDTH,d0
- move.w #PAL_VMID,d6
- move.w #PAL_HEIGHT,d4
- calc_vals:
- move.w d0,width
- move.w d4,height
- move.w d0,d1
- asr.w #1,d1 /* Width/2 */
- sub.w d1,d2 /* Mid - Width/2 */
- addq.w #4,d2 /* (Mid - Width/2)+4 */
- subq.w #1,d1 /* Width/2 - 1 */
- ori.w #0x0400,d1 /* (Width/2 - 1)|0x400 */
- move.w d1,a_hde
- move.w d1,HDE
- move.w d2,a_hdb
- move.w d2,HDB1
- move.w d2,HDB2
- move.w d6,d5
- sub.w d4,d5
- move.w d5,a_vdb
- add.w d4,d6
- move.w d6,a_vde
- move.w a_vdb,VDB
- move.w #0xFFFF,VDE
- move.l #0,BORD1 /* Black border */
- move.w #0,BG /* Init line buffer to black */
- rts
- | InitLister: Initialize Object List Processor List
- InitLister:
- lea listbuf,a0
- move.l a0,d2 /* Copy */
- addi.l #(LISTSIZE-1)*8,d2 /* Address of STOP object */
- move.l d2,d3 /* Copy for low half */
- lsr.l #8,d2 /* Shift high half into place */
- lsr.l #3,d2
- swap d3 /* Place low half correctly */
- clr.w d3
- lsl.l #5,d3
- | Write first BRANCH object (branch if YPOS > a_vde )
- clr.l d0
- move.l #(BRANCHOBJ|O_BRLT),d1 /* 0x4000 = VC < YPOS */
- or.l d2,d0 /* Do LINK overlay */
- or.l d3,d1
- move.w a_vde,d4 /* for YPOS */
- lsl.w #3,d4 /* Make it bits 13-3 */
- or.w d4,d1
- move.l d0,(a0)+
- move.l d1,(a0)+
- | Write second branch object (branch if YPOS < a_vdb)
- | Note: LINK address is the same so preserve it
- andi.l #0xFF000007,d1 /* Mask off CC and YPOS */
- ori.l #O_BRGT,d1 /* 0x8000 = VC > YPOS */
- move.w a_vdb,d4 /* for YPOS */
- lsl.w #3,d4 /* Make it bits 13-3 */
- or.w d4,d1
- move.l d0,(a0)+
- move.l d1,(a0)+
- | Write a standard BITMAP object
- move.l d2,d0
- move.l d3,d1
- ori.l #BMP_HEIGHT<<14,d1 /* Height of image */
- move.w height,d4 /* Center bitmap vertically */
- sub.w #BMP_HEIGHT,d4
- add.w a_vdb,d4
- andi.w #0xFFFE,d4 /* Must be even */
- lsl.w #3,d4
- or.w d4,d1 /* Stuff YPOS in low phrase */
- move.l #_vidmem,d4
- lsl.l #8,d4
- or.l d4,d0
- move.l d0,(a0)+
- move.l d1,(a0)+
- movem.l d0-d1,bmp1update
- move.l #_vidmem+(BMP_PHRASES*BMP_HEIGHT*8*2),d4
- lsl.l #8,d4
- or.l d4,d0
- movem.l d0-d1,bmp2update
- | Second Phrase of Bitmap
- move.l #BMP_PHRASES>>4,d0 /* Only part of top LONG is IWIDTH */
- move.l #BMP_DEPTH|O_NOGAP,d1 /* Bit Depth, Contiguous data */
- move.w width,d4 /* Get width in clocks */
- lsr.w #PIX_SHIFT,d4 /* Pixel Divisor */
- sub.w #BMP_WIDTH,d4
- lsr.w #1,d4 /* horz offset */
- or.w d4,d1
- ori.l #(BMP_PHRASES<<18)|(BMP_PHRASES<<28),d1 /* DWIDTH|IWIDTH */
- move.l d0,(a0)+
- move.l d1,(a0)+
- | Write a STOP object at end of list
- clr.l (a0)+
- move.l #(STOPOBJ|O_STOPINTS),(a0)+
- rts
- | Procedure: UpdateList
- | Handle Video Interrupt and update object list fields
- | destroyed by the object processor.
- UpdateList:
- move.l a0,-(sp)
- move.l #listbuf+BITMAP_OFF,a0
- tst.b frame+1
- bne.b 0f /* second bitmap */
- move.l bmp1update,(a0) /* phrase = d1.l/d0.l */
- move.l bmp1update+4,4(a0)
- bra.b 1f
- 0:
- move.l bmp2update,(a0) /* phrase = d1.l/d0.l */
- move.l bmp2update+4,4(a0)
- 1:
- move.b frame+1,frame /* update bitmap frame selected */
- addq.l #1,ticks /* increment ticks */
- move.w #0x0101,INT1 /* signal we're done */
- move.w #0x0000,INT2
- move.l (sp)+,a0
- rte
- init_hardware:
- clr.l ticks
- clr.w frame
- jsr InitVideo /* setup our video registers */
- jsr InitLister /* initialize Object Display List */
- jsr InitVBint /* initialize our VBLANK routine */
- | sneaky trick to cause display to popup at first VB
- move.l #0x0,listbuf+BITMAP_OFF
- move.l #0xC,listbuf+BITMAP_OFF+4
- move.l #listbuf,OLP /* setting with 68000 may be dangerous */
- move.w #(PIX_WIDTH|BGEN|CSYNC|SCR_MODE|VIDEN),VMODE /* configure Video */
- rts
- .bss
- .balign 16
- .comm listbuf, LISTSIZE*8 /* Object List (in phrases) */
- .comm bmp1update, 8 /* One Phrase of First Bitmap for Refresh */
- .comm bmp2update, 8 /* One Phrase of Second Bitmap for Refresh */
- .comm ticks, 4 /* Incrementing # of ticks */
- .comm a_hdb, 2
- .comm a_hde, 2
- .comm a_vdb, 2
- .comm a_vde, 2
- .comm width, 2
- .comm height, 2
- .comm frame, 2 /* Bitmap selector: MSB = current frame, LSB = frame to select next VBI */
- .balign 4
- .comm __stack_save, 4
- .balign 16
- .comm _vidmem, (BMP_PHRASES*BMP_HEIGHT*8*2)
- .text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement