sb: start using big sprites

This commit is contained in:
Vince Weaver 2023-06-02 16:37:01 -04:00
parent b29f0334ae
commit 34401d1dac
7 changed files with 201 additions and 11 deletions

View File

@ -60,6 +60,8 @@ ASPLODE: asplode.o
asplode.o: asplode.s zx02_optim.s \
asplode_graphics/sb_title.hgr.zx02 \
asplode_graphics/sb_zone.hgr.zx02 \
asplode_graphics/sb_sprites.inc \
hgr_sprite_big.s \
zp.inc hardware.inc
ca65 -o asplode.o asplode.s -l asplode.lst

View File

@ -1,3 +1,5 @@
; Strongbad Zone
;
; Yet Another HR project
;
; by deater (Vince Weaver) <vince@deater.net>
@ -19,7 +21,13 @@ hires_start:
bit SET_GR
bit PAGE1
;====================
; set up tables
;====================
lda #$20
sta HGR_PAGE
jsr hgr_make_tables
;==========================
; Load Title
@ -38,18 +46,14 @@ load_title:
jsr wait_until_keypress
;===================
; Load graphics
; setup game
;===================
load_loop:
;=============================
;==========================
; Load Image
; Load Background
;===========================
load_image:
load_background:
; size in ldsizeh:ldsizel (f1/f0)
@ -64,9 +68,88 @@ load_image:
jsr full_decomp
jsr wait_until_keypress
lda #16
sta STRONGBAD_X
sta PLAYER_X
which_ok:
;==========================
; main loop
;===========================
main_loop:
;==========================
; draw head
;===========================
lda #<head_sprite
sta INL
lda #>head_sprite
sta INH
lda STRONGBAD_X
sta SPRITE_X
lda #36
sta SPRITE_Y
jsr hgr_draw_sprite
;==========================
; draw player
;===========================
lda #<player_sprite
sta INL
lda #>player_sprite
sta INH
lda PLAYER_X
sta SPRITE_X
lda #138
sta SPRITE_Y
jsr hgr_draw_sprite
check_keypress:
lda KEYPRESS
bpl check_keypress
bit KEYRESET ; clear the keyboard strobe
; clear high bit
and #$7f
; FIXME: adjust for lowercase too
cmp #'Q'
beq done_game
cmp #27 ; escape
beq done_game
cmp #'A' ; shield left
cmp #'S' ; shield center
cmp #'D' ; shield right
cmp #8 ; left
beq move_left
cmp #$15
beq move_right ; right
done_keyboard_check:
jmp check_keypress
move_left:
dec PLAYER_X
jmp main_loop
move_right:
inc PLAYER_X
jmp main_loop
;==========================
; done game
;==========================
done_game:
lda #0
sta WHICH_LOAD
rts
@ -80,8 +163,11 @@ wait_until_keypress:
bit KEYRESET ; clear the keyboard buffer
rts
.include "hgr_tables.s"
.include "zx02_optim.s"
.include "hgr_sprite_big.s"
.include "asplode_graphics/sb_sprites.inc"
title_data:
.incbin "asplode_graphics/sb_title.hgr.zx02"

View File

@ -10,7 +10,7 @@ PNG2GR = ../../../utils/gr-utils/png2gr
PNG2SPRITES = ../../../utils/gr-utils/png2sprites
HGR_SPRITE = ../../../utils/hgr-utils/hgr_make_sprite
all: sb_zone.hgr.zx02 sb_title.hgr.zx02
all: sb_zone.hgr.zx02 sb_title.hgr.zx02 sb_sprites.inc
####
@ -29,6 +29,15 @@ sb_title.hgr: sb_title.png
$(PNG_TO_HGR) sb_title.png > sb_title.hgr
####
sb_sprites.inc: sb_sprites.png
$(HGR_SPRITE) -s -l head_sprite sb_sprites.png 84 36 132 92 > sb_sprites.inc
$(HGR_SPRITE) -s -l player_sprite sb_sprites.png 112 138 167 192 >> sb_sprites.inc
####
clean:

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

91
games/sb/hgr_sprite_big.s Normal file
View File

@ -0,0 +1,91 @@
;===========================================
; 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
; if > 1 page
bne sprite_no_page_cross
inc sprite_smc1+2
sprite_no_page_cross:
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

@ -62,6 +62,8 @@ SOUND_STATUS = $67
MENU_ITEM = $68
OLD_MENU_ITEM = $69
NOT_FIRST_TIME = $6A
STRONGBAD_X = $6B
PLAYER_X = $6C
.if 0
REGISTER_DUMP = $70