**************************************************************************** **************************************************************************** ** ** 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 July 26, 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 moveq #7,d7 btst #2,back_type+1(a5) bne.s sides_only move.w starfield_y(a5),d6 and.w #127,d6 moveq #8,d5 moveq #8,d4 lea 8(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 lea 6(a5),a3 moveq #2,d5 moveq #8,d4 lea edge_map(pc),a4 lea edge_tiles(pc),a2 bsr Render_Background_Column lea 24(a5),a3 addq.w #1,a4 bsr Render_Background_Column rts ******************************************** 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: 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 bsr render_tile_loop draw_main_tiles: moveq #4,d3 draw_main_tiles_loop: 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 dbra d3,draw_main_tiles_loop move.w d6,d0 subq.w #1,d0 and.w #15,d0 ; D0 = # lines of bottom tile beq.s rtr subq.w #1,d0 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),3200(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 ******************************************** TILE DATA starfield_map: INCLUDE starmap.i starfield_tiles: INCLUDE startile.i edge_map: INCLUDE edgemap.i edge_tiles: INCLUDE edgetile.i