From eef30bc25884896ac8262e261ff6e1846c280a42 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 13 Mar 2024 00:46:34 -0400 Subject: [PATCH] keen: working on making it full screen --- games/duke/NOTES | 23 +++++++++++++++ games/keen/NOTES | 23 +++++++++++++++ games/keen/actions_level1.s | 8 ++--- games/keen/common_defines.inc | 6 ++-- games/keen/draw_tilemap.s | 55 +++++++++++++++++++++++------------ games/keen/handle_laser.s | 2 +- games/keen/item_level1.s | 2 +- games/keen/keen_level1.s | 22 +++++++++----- games/keen/move_keen.s | 8 ++--- 9 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 games/keen/NOTES diff --git a/games/duke/NOTES b/games/duke/NOTES index 4bad6d7f..645e0250 100644 --- a/games/duke/NOTES +++ b/games/duke/NOTES @@ -8,3 +8,26 @@ $9400 -- global tilemap $BC00 -- local tilemap subset $BD00 -- unused $C000 -- ROM + + +Memory map: + $0000-$00ff = zero page + $0100-$01ff = stack + $0200-$03ff = ??? + $0400-$07ff = lo-res page1 + $0800-$0bff = lo-res page2 + $0c00-$0fff = background image + $1000-$1fff = loader + $2000-????? = code + $9000-$93ff = tiles (1k) + $9400-????? = big_tilemap (10k) + $BC00-????? = tilemap (1k) 10x16 + +tiles are 2x4, or 4 bytes each + so in theory can have up to 256 of them + in 16x16 grid + tilemap is 256 wide by 40 tall = 10k + +Tiles: + hard tiles start at 32 + diff --git a/games/keen/NOTES b/games/keen/NOTES new file mode 100644 index 00000000..f299bf2e --- /dev/null +++ b/games/keen/NOTES @@ -0,0 +1,23 @@ + + +Memory map: + $0000-$00ff = zero page + $0100-$01ff = stack + $0200-$03ff = ??? + $0400-$07ff = lo-res page1 + $0800-$0bff = lo-res page2 + $0c00-$0fff = background image + $1000-$1fff = loader + $2000-????? = code + $9000-$93ff = tiles (1k) + $9400-????? = big_tilemap (10k) + $BC00-????? = tilemap (1k) 10x16 + +tiles are 2x4, or 4 bytes each + so in theory can have up to 256 of them + in 16x16 grid + tilemap is 256 wide by 40 tall = 10k + +Tiles: + hard tiles start at 32 + diff --git a/games/keen/actions_level1.s b/games/keen/actions_level1.s index 6b153c60..030effcd 100644 --- a/games/keen/actions_level1.s +++ b/games/keen/actions_level1.s @@ -58,7 +58,7 @@ no_red_key: ; there has to be a more efficient way of doing this open_the_wall: ; reset smc - lda #>BIG_TILEMAP + lda #>big_tilemap sta rwr_smc1+2 sta rwr_smc2+2 @@ -66,12 +66,12 @@ remove_red_wall_outer: ldx #0 remove_red_wall_loop: rwr_smc1: - lda BIG_TILEMAP,X + lda big_tilemap,X cmp #49 ; red key tile bne not_red_tile lda #2 ; lblue bg tile rwr_smc2: - sta BIG_TILEMAP,X + sta big_tilemap,X not_red_tile: inx bne remove_red_wall_loop @@ -80,7 +80,7 @@ not_red_tile: inc rwr_smc2+2 lda rwr_smc1+2 - cmp #(>BIG_TILEMAP)+40 + cmp #(>big_tilemap)+40 bne remove_red_wall_outer ; refresh local tilemap diff --git a/games/keen/common_defines.inc b/games/keen/common_defines.inc index 88decac8..412aec8a 100644 --- a/games/keen/common_defines.inc +++ b/games/keen/common_defines.inc @@ -4,7 +4,7 @@ LOAD_KEEN1 = 2 LOAD_KEEN2 = 3 -TILES = $9000 -BIG_TILEMAP = $9400 -TILEMAP = $BC00 +tiles = $9000 +big_tilemap = $9400 +tilemap = $BC00 diff --git a/games/keen/draw_tilemap.s b/games/keen/draw_tilemap.s index 677dd7a0..0747b3a4 100644 --- a/games/keen/draw_tilemap.s +++ b/games/keen/draw_tilemap.s @@ -2,6 +2,8 @@ ; draw local tilemap to screen ;================================ + ; tilemap is 20x12 grid with 2x4 (well, 2x2) tiles + draw_tilemap: ldy #0 ; Y on screen currently drawing sty tiley ; we draw two at a time @@ -13,7 +15,7 @@ draw_tilemap: sta tile_odd tilemap_outer_loop: - ldy tiley ; setup pointer to current Y + ldy tiley ; setup output pointer to current Y lda gr_offsets,Y sta GBASL lda gr_offsets+1,Y @@ -21,10 +23,12 @@ tilemap_outer_loop: adc DRAW_PAGE sta GBASH - ldy #6 ; we draw in window 6->34 + + ldy #0 +; ldy #6 ; we draw in window 6->34 tilemap_loop: ldx tilemap_offset ; get actual tile - lda TILEMAP,X + lda tilemap,X asl ; *4 ; get offset in tile asl @@ -36,14 +40,14 @@ tilemap_loop: inx not_odd_line: - lda TILES,X ; draw two tiles + lda tiles,X ; draw two tiles cmp #$AA ; transparency beq skip_tile1 sta (GBASL),Y skip_tile1: iny - lda TILES+1,X + lda tiles+1,X cmp #$AA beq skip_tile2 sta (GBASL),Y @@ -52,7 +56,8 @@ skip_tile2: inc tilemap_offset - cpy #34 ; until done + cpy #40 ; until done +; cpy #34 ; until done bne tilemap_loop ; move to next line @@ -61,6 +66,7 @@ skip_tile2: sta tile_odd bne move_to_odd_line + ; ???? move_to_even_line: lda tilemap_offset clc @@ -75,12 +81,13 @@ move_to_odd_line: done_move_to_line: sta tilemap_offset - ldy tiley ; move to next line + ldy tiley ; move to next output line iny iny sty tiley - cpy #40 ; check if at end + cpy #48 ; check if at end +; cpy #40 ; check if at end bne tilemap_outer_loop rts @@ -96,21 +103,33 @@ tiley: .byte $00 ;=================================== ; want to copy a 16x10 area from global tileset to local - ; default at first we want to start at 128,88 - ; which is 13, 20??? + ; originally 16x10 16x10 = 160 bytes + ; extend to 20x12 for full screen? 20x12 = 240 bytes + + ; big tilemap is 256*40 + ; so each row is a page + + ; TILEMAP_X, TILEMAP_Y specify where in big + + ; copy to tilemap + +TILEMAP_X_COPY_SIZE = 20 +TILEMAP_Y_COPY_SIZE = 12 copy_tilemap_subset: ; set start lda TILEMAP_Y - clc - adc #>BIG_TILEMAP + clc ; set start + adc #>big_tilemap ; each row is a page, so adding + ; Y to top byte is indexing to row + sta cptl1_smc+2 ; set proper row in big tilemap - adc #$10 - sta cptl3_smc+1 ; set loop limit + adc #TILEMAP_Y_COPY_SIZE + sta cptl3_smc+1 ; set loop limit (end) ; reset row - lda #