fn: first implementation

This commit is contained in:
Vince Weaver 2023-05-02 22:10:19 -04:00
parent abf18eb43c
commit cb84455f65
5 changed files with 164 additions and 23 deletions

View File

@ -34,7 +34,7 @@ sb.o: sb.s zx02_optim.s \
FN: fn.o
ld65 -o FN fn.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
fn.o: fn.s zx02_optim.s duet.s hgr_sprite_mask.s hgr_tables.s \
fn.o: fn.s zx02_optim.s duet.s hgr_sprite_mask.s hgr_sprite.s hgr_tables.s \
zp.inc hardware.inc \
fn_sound/fortnight.ed \
fn_graphics/a2_fortnight.hgr.zx02 \

View File

@ -25,6 +25,9 @@ fortnight_start:
bit SET_GR
bit PAGE1
ldx #0
sta FRAME
sta FRAMEH
;==========================
; Floppy Animation
@ -32,6 +35,7 @@ fortnight_start:
floppy_animation:
; decompress background to page1
lda #<fn_image
sta ZX0_src
@ -39,9 +43,20 @@ floppy_animation:
sta ZX0_src+1
lda #$20
jsr full_decomp
; decompress background to page2
; would it be faster to copy?
lda #<fn_image
sta ZX0_src
lda #>fn_image
sta ZX0_src+1
lda #$40
jsr full_decomp
reset_floppy_loop:
lda #0
sta XPOS
@ -61,9 +76,43 @@ floppy_loop:
lda floppy_mask_h,X
sta MASKH
; draw sprite
jsr hgr_draw_sprite_mask_and_save
time_loop:
lda KEYPRESS ; 4
bmi done_floppy
lda #160
jsr WAIT
; jsr wait_until_keypress
; see if end
inc FRAME
bne no_frame_oflo
inc FRAMEH
no_frame_oflo:
lda FRAMEH
cmp #3
beq done_floppy
lda FRAME
and #$3
bne time_loop
; erase sprite
lda #<backup_sprite
sta INL
lda #>backup_sprite
sta INH
jsr hgr_draw_sprite
jsr wait_until_keypress
; move sprite
inc XPOS
lda XPOS
@ -71,7 +120,8 @@ floppy_loop:
bcc floppy_loop
bcs reset_floppy_loop
done_floppy:
bit KEYRESET ; clear the keyboard buffer
;==========================
; "breakdancing" rat
@ -127,6 +177,7 @@ wait_until_keypress:
.include "zx02_optim.s"
.include "hgr_sprite.s"
.include "hgr_sprite_mask.s"
.include "hgr_tables.s"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 14 KiB

83
games/sb/hgr_sprite.s Normal file
View File

@ -0,0 +1,83 @@
;===========================================
; hgr draw sprite (only at 7-bit boundaries)
;===========================================
; SPRITE in INL/INH
; Location at CURSOR_X CURSOR_Y
; xsize, ysize in first two bytes
; sprite AT INL/INH
hgr_draw_sprite:
ldy #0
lda (INL),Y ; load xsize
clc
adc CURSOR_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 CURSOR_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
sta GBASH
; eor #$60
; sta INH
ldy CURSOR_X
sprite_inner_loop:
sprite_smc1:
lda $f000,X ; load sprite data
sta (GBASL),Y ; store to screen
inx ; increment sprite offset
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

View File

@ -1,5 +1,5 @@
;===========================================
; hgr draw sprite (only at 7-bit boundaries)
; hgr draw sprite mask and save (only at 7-bit boundaries)
;===========================================
; SPRITE in INL/INH
; Location at CURSOR_X CURSOR_Y
@ -8,35 +8,37 @@
; sprite AT INL/INH
hgr_draw_sprite:
hgr_draw_sprite_mask_and_save:
ldy #0
lda (INL),Y ; load xsize
sta backup_sprite
clc
adc CURSOR_X
sta sprite_width_end_smc+1 ; self modify for end of line
sta sms_sprite_width_end_smc+1 ; self modify for end of line
iny ; load ysize
lda (INL),Y
sta sprite_ysize_smc+1 ; self modify
sta backup_sprite+1
sta sms_sprite_ysize_smc+1 ; self modify
; point smc to sprite
lda INL ; 16-bit add
sta sprite_smc1+1
sta sms_sprite_smc1+1
lda INH
sta sprite_smc1+2
sta sms_sprite_smc1+2
lda MASKL
sta mask_smc1+1
sta sms_mask_smc1+1
lda MASKH
sta mask_smc1+2
sta sms_mask_smc1+2
ldx #0 ; X is pointer offset
stx CURRENT_ROW ; actual row
ldx #2
hgr_sprite_yloop:
hgr_sms_sprite_yloop:
lda CURRENT_ROW ; row
@ -48,42 +50,47 @@ hgr_sprite_yloop:
tay ; get output ROW into GBASL/H
lda hposn_low,Y
sta GBASL
; sta INL
lda hposn_high,Y
; eor #$00 draws on page2
; eor #$60 draws on page1
hgr_sprite_page_smc:
eor #$00
;hgr_sprite_page_smc:
; eor #$00
sta GBASH
; eor #$60
; sta INH
ldy CURSOR_X
sprite_inner_loop:
sms_sprite_inner_loop:
lda (GBASL),Y ; load bg
sprite_smc1:
lda (GBASL),Y ; load bg
sta backup_sprite,X
sms_sprite_smc1:
eor $f000,X ; load sprite data
mask_smc1:
sms_mask_smc1:
and $f000,X
eor (GBASL),Y
sta (GBASL),Y
sta (GBASL),Y ; store to screen
inx ; increment sprite offset
iny ; increment output position
sprite_width_end_smc:
sms_sprite_width_end_smc:
cpy #6 ; see if reached end of row
bne sprite_inner_loop ; if not, loop
bne sms_sprite_inner_loop ; if not, loop
inc CURRENT_ROW ; row
lda CURRENT_ROW ; row
sprite_ysize_smc:
sms_sprite_ysize_smc:
cmp #31 ; see if at end
bne hgr_sprite_yloop ; if not, loop
bne hgr_sms_sprite_yloop ; if not, loop
rts
backup_sprite = $1800