mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-12-29 00:31:52 +00:00
peasant_mini: horribl sprite code
but it works for now
This commit is contained in:
parent
052bc05943
commit
2ca8929229
@ -29,15 +29,24 @@ CLIFF: cliff.o
|
||||
|
||||
cliff.o: cliff.s zx02_optim.s \
|
||||
hgr_copy.s hgr_partial_save.s \
|
||||
hgr_sprite.s \
|
||||
cliff_graphics/cliff_base.hgr.zx02 \
|
||||
sprites/enemy_sprites.inc \
|
||||
zp.inc hardware.inc
|
||||
ca65 -o cliff.o cliff.s -l cliff.lst
|
||||
|
||||
####
|
||||
|
||||
cliff_graphics/cliff_base.hgr.zx02:
|
||||
cd cliff_graphics && make
|
||||
|
||||
sprites/enemy_sprites.inc:
|
||||
cd sprites && make
|
||||
|
||||
|
||||
####
|
||||
|
||||
clean:
|
||||
rm -f *.lst *.o CLIFF HELLO
|
||||
cd cliff_graphics && make clean
|
||||
cd sprites && make clean
|
||||
|
@ -110,6 +110,60 @@ game_loop:
|
||||
|
||||
jsr draw_peasant
|
||||
|
||||
|
||||
;=====================
|
||||
; draw enemies
|
||||
|
||||
lda #$20 ; backup location
|
||||
sta OUTH
|
||||
lda #$00
|
||||
sta OUTL
|
||||
|
||||
lda #8
|
||||
sta SPRITE_X
|
||||
|
||||
lda #100
|
||||
sta SPRITE_Y
|
||||
|
||||
lda #<bird0_sprite
|
||||
sta INL
|
||||
lda #>bird0_sprite
|
||||
sta INH
|
||||
|
||||
lda #<bird0_mask
|
||||
sta MASKL
|
||||
lda #>bird0_mask
|
||||
sta MASKH
|
||||
|
||||
jsr hgr_draw_sprite
|
||||
|
||||
lda #$21 ; backup location
|
||||
sta OUTH
|
||||
lda #$00
|
||||
sta OUTL
|
||||
|
||||
lda #21
|
||||
sta SPRITE_X
|
||||
|
||||
lda #89
|
||||
sta SPRITE_Y
|
||||
|
||||
lda #<bird1_sprite
|
||||
sta INL
|
||||
lda #>bird1_sprite
|
||||
sta INH
|
||||
|
||||
lda #<bird1_mask
|
||||
sta MASKL
|
||||
lda #>bird1_mask
|
||||
sta MASKH
|
||||
|
||||
jsr hgr_draw_sprite
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
;=====================
|
||||
; increment frame
|
||||
|
||||
@ -139,6 +193,8 @@ done_cliff:
|
||||
|
||||
.include "hgr_tables.s"
|
||||
|
||||
.include "hgr_sprite.s"
|
||||
|
||||
.include "zx02_optim.s"
|
||||
|
||||
.include "wait.s"
|
||||
@ -162,7 +218,7 @@ bg_data:
|
||||
.incbin "cliff_graphics/cliff_base.hgr.zx02"
|
||||
|
||||
priority_data:
|
||||
|
||||
.incbin "cliff_graphics/cliff_base_priority.zx02"
|
||||
|
||||
|
||||
sprites:
|
||||
.include "sprites/enemy_sprites.inc"
|
||||
|
238
games/peasant_mini/cliff/hgr_sprite.s
Normal file
238
games/peasant_mini/cliff/hgr_sprite.s
Normal file
@ -0,0 +1,238 @@
|
||||
;===========================================
|
||||
; hgr draw sprite (only at 7-bit boundaries)
|
||||
;===========================================
|
||||
; attempts to shift to allow arbitray odd/even columns
|
||||
;
|
||||
; *cannot* handle sprites bigger than a 256 byte page
|
||||
|
||||
; SPRITE in INL/INH
|
||||
; note: xsize,ysize in first two bytes
|
||||
; total bytes in text two bytes
|
||||
; mask data immediately follows sprite data
|
||||
|
||||
; Location at SPRITE_X SPRITE_Y
|
||||
; note: sprite_x is column, so Xcoord/7
|
||||
|
||||
; Save at OUTL/OUTH
|
||||
|
||||
hgr_draw_sprite:
|
||||
lda SPRITE_X
|
||||
ror
|
||||
bcs hgr_draw_sprite_odd
|
||||
|
||||
hgr_draw_sprite_even:
|
||||
ldy #0
|
||||
lda (INL),Y ; load xsize
|
||||
sta (OUTL),Y ; store to screen backup
|
||||
clc
|
||||
adc SPRITE_X
|
||||
sta sprite_width_end_smc+1 ; self modify for end of line
|
||||
|
||||
iny ; load ysize
|
||||
lda (INL),Y
|
||||
sta (OUTL),Y ; store to screen backup
|
||||
sta sprite_ysize_smc+1 ; self modify for end row
|
||||
|
||||
; point smc to sprite
|
||||
lda INL
|
||||
sta sprite_smc1+1
|
||||
lda INH
|
||||
sta sprite_smc1+2
|
||||
sta INH
|
||||
|
||||
; point smc to backup
|
||||
lda OUTL
|
||||
sta backup_sprite_smc1+1
|
||||
lda OUTH
|
||||
sta backup_sprite_smc1+2
|
||||
|
||||
; point smc to mask
|
||||
lda MASKL
|
||||
sta sprite_mask_smc1+1
|
||||
lda MASKH
|
||||
sta sprite_mask_smc1+2
|
||||
|
||||
ldx #0 ; X is pointer offset
|
||||
stx CURRENT_ROW ; actual row
|
||||
|
||||
ldx #2 ; start two bytes in (past x/y)
|
||||
|
||||
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
|
||||
|
||||
clc
|
||||
adc DRAW_PAGE
|
||||
sta GBASH
|
||||
|
||||
ldy SPRITE_X
|
||||
|
||||
sprite_inner_loop:
|
||||
|
||||
lda (GBASL),Y ; load bg
|
||||
backup_sprite_smc1:
|
||||
sta $f000,X
|
||||
sprite_smc1:
|
||||
eor $f000,X ; load sprite data
|
||||
sprite_mask_smc1:
|
||||
and $f000,X
|
||||
eor (GBASL),Y
|
||||
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
|
||||
|
||||
hgr_draw_sprite_odd:
|
||||
|
||||
ldy #0
|
||||
lda (INL),Y ; load xsize
|
||||
sta (OUTL),Y ; store to screen backup
|
||||
clc
|
||||
adc SPRITE_X
|
||||
sta osprite_width_end_smc+1 ; self modify for end of line
|
||||
|
||||
iny
|
||||
lda (INL),Y ; load ysize
|
||||
sta (OUTL),Y ; store to screen backup
|
||||
sta osprite_ysize_smc+1 ; self modify for end row
|
||||
|
||||
; point smc to sprite
|
||||
lda INL
|
||||
sta osprite_smc1+1
|
||||
lda INH
|
||||
sta osprite_smc1+2
|
||||
|
||||
; point smc to backup
|
||||
lda OUTL
|
||||
sta obackup_sprite_smc1+1
|
||||
lda OUTH
|
||||
sta obackup_sprite_smc1+2
|
||||
|
||||
; point smc to mask
|
||||
lda MASKL
|
||||
sta osprite_mask_smc1+1
|
||||
lda MASKH
|
||||
sta osprite_mask_smc1+2
|
||||
|
||||
|
||||
ldx #0 ; X is pointer offset
|
||||
stx CURRENT_ROW ; actual row
|
||||
|
||||
ldx #2
|
||||
|
||||
ohgr_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
|
||||
|
||||
clc
|
||||
adc DRAW_PAGE
|
||||
sta GBASH
|
||||
|
||||
ldy SPRITE_X
|
||||
|
||||
lda #$0
|
||||
sta SPRITE_TEMP ; default high bit to 0
|
||||
sta MASK_TEMP ; defailt high bit to 0
|
||||
|
||||
osprite_inner_loop:
|
||||
|
||||
lda (GBASL),Y ; load bg data
|
||||
sta TEMP
|
||||
|
||||
obackup_sprite_smc1:
|
||||
sta $f000,X ; store backup
|
||||
|
||||
osprite_mask_smc1:
|
||||
lda $f000,X ; load mask data
|
||||
|
||||
eor #$FF
|
||||
|
||||
rol MASK_TEMP
|
||||
rol
|
||||
sta MASK_TEMP
|
||||
|
||||
and TEMP
|
||||
sta TEMP
|
||||
|
||||
osprite_smc1:
|
||||
lda $f000,X ; load sprite data
|
||||
|
||||
rol SPRITE_TEMP
|
||||
rol
|
||||
sta SPRITE_TEMP
|
||||
ora TEMP
|
||||
|
||||
and #$7f ; force purple/green
|
||||
|
||||
sta (GBASL),Y ; store to screen
|
||||
|
||||
|
||||
inx ; increment sprite offset
|
||||
iny ; increment output position
|
||||
|
||||
|
||||
|
||||
osprite_width_end_smc:
|
||||
cpy #6 ; see if reached end of row
|
||||
bne osprite_inner_loop ; if not, loop
|
||||
|
||||
inc CURRENT_ROW ; row
|
||||
lda CURRENT_ROW ; row
|
||||
|
||||
osprite_ysize_smc:
|
||||
cmp #31 ; see if at end
|
||||
bne ohgr_sprite_yloop ; if not, loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
.if 0
|
||||
|
||||
|
||||
|
||||
|
||||
;hgr_sprite_page_smc:
|
||||
; eor #$00
|
||||
|
||||
|
||||
|
||||
|
||||
backup_sprite1 = $1800
|
||||
backup_sprite2 = $1900
|
||||
|
||||
.endif
|
14
games/peasant_mini/cliff/sprites/Makefile
Normal file
14
games/peasant_mini/cliff/sprites/Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
HGR_SPRITE = ../../../../utils/hgr-utils/hgr_make_sprite
|
||||
|
||||
all: enemy_sprites.inc
|
||||
|
||||
enemy_sprites.inc: enemy_sprites.png
|
||||
$(HGR_SPRITE) -s -l bird0_sprite enemy_sprites.png 210 50 230 66 > enemy_sprites.inc
|
||||
$(HGR_SPRITE) -s -l bird0_mask enemy_sprites.png 238 50 258 66 >> enemy_sprites.inc
|
||||
$(HGR_SPRITE) -s -l bird1_sprite enemy_sprites.png 210 74 230 88 >> enemy_sprites.inc
|
||||
$(HGR_SPRITE) -s -l bird1_mask enemy_sprites.png 238 74 258 88 >> enemy_sprites.inc
|
||||
|
||||
|
||||
clean:
|
||||
rm -f *~ enemy_sprites.inc
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 5.3 KiB |
@ -16,6 +16,11 @@ DRIVE2_DISK = $0C
|
||||
DRIVE1_TRACK = $0D
|
||||
DRIVE2_TRACK = $0E
|
||||
|
||||
SPRITE_TEMP = $10
|
||||
MASK_TEMP = $11
|
||||
TEMP = $12
|
||||
|
||||
|
||||
TEMP0 = $10
|
||||
TEMP1 = $11
|
||||
TEMP2 = $12
|
||||
@ -271,7 +276,12 @@ P3 = $F4
|
||||
P4 = $F5
|
||||
P5 = $F6
|
||||
|
||||
SPRITE_X = $F7
|
||||
SPRITE_Y = $F8
|
||||
CURRENT_ROW = $F9
|
||||
|
||||
MASKL = $FA
|
||||
MASKH = $FB
|
||||
INL = $FC
|
||||
INH = $FD
|
||||
OUTL = $FE
|
||||
|
Loading…
Reference in New Issue
Block a user