**************************************************************************** **************************************************************************** ** ** Platinum Edition (Background rendering) ** ** This software is in the public domain. There is no warranty. ** ** by Patrick Davidson (pad@calc.org, http://pad.calc.org/) ** ** Last updated September 27, 2001 ** **************************************************************************** **************************************************************************** sides_only: bsr Clear_Screen_Main bra.s draw_sides Draw_Background_Main: tst.w ludicrous(a5) bne.s \always_advance btst #0,cycle_counter+3(a5) beq.s \no_advance \always_advance: subq.w #1,starfield_y(a5) \no_advance: btst #3,back_type+1(a5) bne Clear_Screen_Main btst #2,back_type+1(a5) bne.s sides_only moveq #9,d7 move.w starfield_y(a5),d6 and.w #255,d6 moveq #10,d5 moveq #16,d4 lea 6(a5),a3 lea starfield_map(pc),a4 lea starfield_tiles(pc),a2 \loop_draw: bsr Render_Background_Column addq.w #2,a3 addq.w #1,a4 dbra d7,\loop_draw draw_sides: move.w edge_y(a5),d6 subq.w #1,d6 add.w ludicrous(a5),d6 move.w d6,edge_y(a5) and.w #127,d6 IFD ti89 lea 6(a5),a3 moveq #2,d5 moveq #8,d4 lea edge_map(pc),a4 lea edge_tiles(pc),a2 bsr Render_Background_Column_Over lea 24(a5),a3 addq.w #1,a4 bra Render_Background_Column_Over ENDIF IFND ti89 lea 4(a5),a3 moveq #4,d5 moveq #8,d4 lea edge_map(pc),a4 lea edge_tiles(pc),a2 bsr Render_Background_Column lea 6(a5),a3 addq.w #1,a4 bsr Render_Background_Column_Over lea 24(a5),a3 addq.w #1,a4 bsr Render_Background_Column_Over lea 26(a5),a3 addq.w #1,a4 bra Render_Background_Column ENDIF ******************************************** RENDER BACKGROUND COLUMN * * This routine draws one column of the background onto the screen. It will * read the map at the given Y coordinate to locate the appropriate tile data, * and draws in both planes. Arguments are: * * A4 -> The map (pointer to first entry in this column, entries are bytes) * A3 -> Pointer to this column in first bitplane * A2 -> Tile data (tiles must be 16x16 grayscale) * D6 = starting Y coordinate (must be within map range) * D5 = width (in bytes) of a column in the tile map * D4 = height (in tiles) of column * * This routine modifies A0, A1, A6, and D0 - D3. * ******** Render_Background_Column: moveq #SCREEN_HEIGHT-16,d3 ; D3 = lines remaining to draw lea (a3),a0 move.w d6,d0 lsr.w #4,d0 ; D0 = row in tilemap move.w d0,d2 ; D2 = (generally) row in tilemap mulu d5,d0 lea 0(a4,d0.w),a6 ; A6 = position in tilemap move.w d6,d0 and.w #15,d0 ; D0 = Y coord within top tile beq.s draw_main_tiles moveq #0,d1 move.b (a6),d1 lsl.w #6,d1 add.w d0,d0 add.w d0,d1 lea 0(a2,d1.w),a1 ; A1 -> tile image move.w d6,d0 not.w d0 ; D0 = 15 - Y coord within top tile and.w #15,d0 ; D0 = top tile height - 1 subq.w #1,d3 sub.w d0,d3 ; D3 = lines remaining to draw bsr render_tile_loop draw_main_tiles: moveq #0,d1 move.b (a6),d1 ; get tile # lsl.w #6,d1 lea 0(a2,d1.w),a1 ; A1 -> tile image bsr Render_Tile sub.w #16,d3 bgt.s draw_main_tiles move.w d3,d0 add.w #15,d0 ; D0 = previous D3 - 1 moveq #0,d1 move.b (a6),d1 lsl.w #6,d1 lea 0(a2,d1.w),a1 bra.s render_tile_loop Render_Tile: moveq #15,d0 render_tile_loop: move.w 32(a1),SCREEN_SIZE(a0) ; copy second bitplane move.w (a1)+,(a0) ; copy first bitplane lea 32(a0),a0 dbra d0,render_tile_loop add.w d5,a6 addq.w #1,d2 cmp.w d4,d2 bne.s rtr lea (a4),a6 moveq #0,d2 rtr: rts ******************************************** RENDER BACKGROUND OVERLAY * * As above, but draws column as an overlay and changes D7 also. * ******** Render_Background_Column_Over: moveq #SCREEN_HEIGHT-16,d3 ; D3 = lines remaining to draw lea (a3),a0 move.w d6,d0 lsr.w #4,d0 ; D0 = row in tilemap move.w d0,d2 ; D2 = (generally) row in tilemap mulu d5,d0 lea 0(a4,d0.w),a6 ; A6 = position in tilemap move.w d6,d0 and.w #15,d0 ; D0 = Y coord within top tile beq.s \draw_main_tiles moveq #0,d1 move.b (a6),d1 lsl.w #6,d1 add.w d0,d0 add.w d0,d1 lea 0(a2,d1.w),a1 ; A1 -> tile image move.w d6,d0 not.w d0 ; D0 = 15 - Y coord within top tile and.w #15,d0 ; D0 = top tile height - 1 subq.w #1,d3 sub.w d0,d3 ; D3 = lines remaining to draw bsr \render_tile_loop \draw_main_tiles: moveq #0,d1 move.b (a6),d1 ; get tile # lsl.w #6,d1 lea 0(a2,d1.w),a1 ; A1 -> tile image bsr \Render_Tile sub.w #16,d3 bgt.s \draw_main_tiles move.w d3,d0 add.w #15,d0 ; D0 = previous D3 - 1 moveq #0,d1 move.b (a6),d1 lsl.w #6,d1 lea 0(a2,d1.w),a1 bra.s \render_tile_loop \Render_Tile: moveq #15,d0 \render_tile_loop: move.w 32(a1),d7 or.w (a1),d7 not.w d7 and.w d7,(a0) and.w d7,SCREEN_SIZE(a0) move.w 32(a1),d7 or.w d7,SCREEN_SIZE(a0) ; copy second bitplane move.w (a1)+,d7 or.w d7,(a0) ; copy first bitplane lea 32(a0),a0 dbra d0,\render_tile_loop add.w d5,a6 addq.w #1,d2 cmp.w d4,d2 bne.s \rtr lea (a4),a6 moveq #0,d2 \rtr: rts ******************************************** TILE DATA starfield_map: INCLUDE starmap.i starfield_tiles: INCLUDE startile.i IFD ti89 edge_map: INCLUDE edgemap.i edge_tiles: INCLUDE edgetile.i ENDIF IFND ti89 edge_map: INCLUDE em92.i edge_tiles: INCLUDE et92.i ENDIF