keen: hook up initial title screen

This commit is contained in:
Vince Weaver 2024-05-10 01:21:25 -04:00
parent 54021d7245
commit a07936677c
7 changed files with 278 additions and 4 deletions

View File

@ -60,7 +60,9 @@ TITLE: title.o
title.o: title.s zp.inc hardware.inc \
zx02_optim.s \
graphics/keen1_title.hgr.zx02
hgr_sprite.s hgr_tables.s \
graphics/keen1_title.hgr.zx02 \
graphics/title_sprites.inc
ca65 -o title.o title.s -l title.lst
####

View File

@ -11,12 +11,12 @@ PNG2SPRITES = ../../../utils/gr-utils/png2sprites
HGR_SPRITE = ../../../utils/hgr-utils/hgr_make_sprite
all: keen1_title.hgr.zx02 level1_bg.gr.zx02 parts.gr.zx02 \
keen1_story.hgr.zx02
keen1_story.hgr.zx02 title_sprites.inc
####
#disk_sprites.inc: a2_fortnight_sprites.png
# $(HGR_SPRITE) -s -l disk_sprite0 a2_fortnight_sprites.png 14 7 41 34 > disk_sprites.inc
title_sprites.inc: title_sprites.png
$(HGR_SPRITE) -s -l title_sprite title_sprites.png 0 0 167 95 > title_sprites.inc
####

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

88
games/keen/hgr_sprite.s Normal file
View File

@ -0,0 +1,88 @@
;===========================================
; hgr draw sprite (only at 7-bit boundaries)
;===========================================
; SPRITE in INL/INH
; Location at SPRITE_X SPRITE_Y
; xsize, ysize in first two bytes
; sprite AT INL/INH
hgr_draw_sprite:
ldy #0
lda (INL),Y ; load xsize
clc
adc SPRITE_X
sta sprite_width_end_smc+1 ; self modify for end of line
iny ; load ysize
lda (INL),Y
sta sprite_ysize_smc+1 ; self modify
; point smc to sprite
lda INL ; 16-bit add
sta sprite_smc1+1
lda INH
sta sprite_smc1+2
ldx #0 ; X is pointer offset
stx CURRENT_ROW ; actual row
ldx #2
hgr_sprite_yloop:
lda CURRENT_ROW ; row
clc
adc SPRITE_Y ; add in cursor_y
; calc GBASL/GBASH
tay ; get output ROW into GBASL/H
lda hposn_low,Y
sta GBASL
lda hposn_high,Y
; eor #$00 draws on page2
; eor #$60 draws on page1
;hgr_sprite_page_smc:
; eor #$00
clc
adc DRAW_PAGE
sta GBASH
; eor #$60
; sta INH
ldy SPRITE_X
sprite_inner_loop:
sprite_smc1:
lda $f000,X ; load sprite data
sta (GBASL),Y ; store to screen
inx ; increment sprite offset
bne not_oflo
inc sprite_smc1+2
not_oflo:
iny ; increment output position
sprite_width_end_smc:
cpy #6 ; see if reached end of row
bne sprite_inner_loop ; if not, loop
inc CURRENT_ROW ; row
lda CURRENT_ROW ; row
sprite_ysize_smc:
cmp #31 ; see if at end
bne hgr_sprite_yloop ; if not, loop
rts

146
games/keen/hgr_tables.s Normal file
View File

@ -0,0 +1,146 @@
;div7_table = $9C00
;mod7_table = $9D00
;hposn_high = $9E00
;hposn_low = $9F00
;=====================
; make /7 %7 tables
;=====================
; HGR_PAGE should be $20/$40 to select if default for hposn
; is page1 or page2
hgr_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
; Hposn table
lda #0
hposn_loop:
ldy #0
ldx #0
pha
jsr hposn ; (Y,X),(A)
pla
tax
lda GBASL
sta hposn_low,X
lda GBASH
sta hposn_high,X
inx
txa
cmp #192
bne hposn_loop
rts
; left masks
; in memory on screen
; x111 1111 1111111 start at 0
; x111 1110 0111111 start at 1
; x111 1100 0011111 start at 2
; ...
; x100 0000 0000001 start at 6
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
; right masks
; in memory on screen
; x000 0001 1000000 end at 0
; x000 0011 1100000 end at 1
; x000 0111 1110000 end at 2
; ...
; x011 1111 1111110 end at 5
; x111 1111 1111111 end at 6
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF
; from the Apple II firmware
hposn:
; sta HGR_Y ; save Y and X positions
; stx HGR_X
; sty HGR_X+1
pha ; Y pos on stack
and #$C0 ; calc base addr for Y-pos
sta GBASL
lsr
lsr
ora GBASL
sta GBASL
pla
sta GBASH
asl
asl
asl
rol GBASH
asl
rol GBASH
asl
ror GBASL
lda GBASH
and #$1F
ora HGR_PAGE ; default is $40 in this game
sta GBASH
; txa
; cpy #0
; beq xpos_lessthan_256
; ldy #35
; adc #4
;label_1:
; iny
;xpos_lessthan_256:
; sbc #7
; bcs label_1
rts

View File

@ -9,6 +9,11 @@
.include "hardware.inc"
.include "common_defines.inc"
div7_table = $9C00
mod7_table = $9D00
hposn_high = $9E00
hposn_low = $9F00
keen_title_start:
;===================
; init screen
@ -158,6 +163,13 @@ mockingboard_notfound:
done_setup_sound:
;===================================
; init
;===================================
lda #$0
sta HGR_PAGE
jsr hgr_make_tables
;===================================
; Do Intro Sequence
@ -168,6 +180,25 @@ done_setup_sound:
lda #100
jsr wait_a_bit
lda #<title_sprite
sta INL
lda #>title_sprite
sta INH
lda #8
sta SPRITE_X
lda #48
sta SPRITE_Y
lda #$20
sta DRAW_PAGE
jsr hgr_draw_sprite
lda #100
jsr wait_a_bit
done_intro:
@ -233,6 +264,8 @@ init_vars:
.include "text_help.s"
.include "gr_fast_clear.s"
.include "text_print.s"
.include "hgr_sprite.s"
.include "hgr_tables.s"
; .include "lc_detect.s"
@ -247,6 +280,7 @@ init_vars:
new_title:
.incbin "graphics/keen1_title.hgr.zx02"
.include "graphics/title_sprites.inc"
;====================================

View File

@ -159,6 +159,10 @@ SOUNDL = $B2
SOUNDH = $B3
START_LINE_L = $B4 ; story
START_LINE_H = $B5 ; story
SPRITE_Y = $B6 ; title
CURRENT_ROW = $B7 ; title
SPRITE_X = $B8 ; title
HGR_PAGE = $B9 ; title
WHICH_SLOT = $DA
JS_BUTTON_STATE = $DB