mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-07 21:30:39 +00:00
trogdor: sprites
This commit is contained in:
parent
68306e1533
commit
d4219e75e3
@ -136,7 +136,8 @@ TROGDOR: trogdor.o
|
||||
|
||||
trogdor.o: trogdor.s \
|
||||
zp.inc hardware.inc qload.inc \
|
||||
graphics/trog00_trogdor.hgr.zx02
|
||||
graphics/trog00_trogdor.hgr.zx02 \
|
||||
hgr_sprite_big_mask.s
|
||||
ca65 -o trogdor.o trogdor.s -l trogdor.lst
|
||||
|
||||
|
||||
|
@ -18,7 +18,21 @@ all: \
|
||||
trog10_peasants.hgr.zx02 \
|
||||
trog11_cottage.hgr.zx02 \
|
||||
a2_strongbad.hgr.zx02 \
|
||||
trogdor.hgr.zx02
|
||||
trogdor.hgr.zx02 \
|
||||
flame_sprites.inc
|
||||
|
||||
####
|
||||
|
||||
flame_sprites.inc: compact_flames.png
|
||||
$(HGR_SPRITE) -s -l left_flame_small ./compact_flames.png 0 8 55 48 > flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l right_flame_small ./compact_flames.png 56 8 111 48 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l left_flame_big ./compact_flames.png 0 54 55 192 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l right_flame_big ./compact_flames.png 56 54 111 192 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l left_flame_small_mask ./compact_flames.png 112 8 167 48 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l right_flame_small_mask ./compact_flames.png 168 8 223 48 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l left_flame_big_mask ./compact_flames.png 112 54 167 192 >> flame_sprites.inc
|
||||
$(HGR_SPRITE) -s -l right_flame_big_mask ./compact_flames.png 168 54 223 192 >> flame_sprites.inc
|
||||
|
||||
|
||||
####
|
||||
|
||||
|
BIN
demos/trogdor/graphics/compact_flames.png
Normal file
BIN
demos/trogdor/graphics/compact_flames.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -1,205 +0,0 @@
|
||||
;===========================================
|
||||
; hgr draw sprite (only at 7-bit boundaries)
|
||||
;===========================================
|
||||
; can handle sprites bigger than a 256 byte page
|
||||
|
||||
; Note this is optimized for blue/orange sprites
|
||||
; it treats black0 as transparent
|
||||
|
||||
; SPRITE in INL/INH
|
||||
; Location at SPRITE_X SPRITE_Y
|
||||
|
||||
; xsize, ysize in first two bytes
|
||||
|
||||
; sprite AT INL/INH
|
||||
|
||||
|
||||
; orange = color5 1 101 0101 1 010 1010
|
||||
|
||||
hgr_draw_sprite_big:
|
||||
lda SPRITE_X
|
||||
ror
|
||||
bcs hgr_draw_sprite_big_odd
|
||||
|
||||
hgr_draw_sprite_big_even:
|
||||
ldy #0
|
||||
lda (INL),Y ; load xsize
|
||||
clc
|
||||
adc SPRITE_X
|
||||
sta big_sprite_width_end_smc+1 ; self modify for end of line
|
||||
|
||||
iny ; load ysize
|
||||
lda (INL),Y
|
||||
sta big_sprite_ysize_smc+1 ; self modify
|
||||
|
||||
; point smc to sprite
|
||||
lda INL ; 16-bit add
|
||||
sta big_sprite_smc1+1
|
||||
lda INH
|
||||
sta big_sprite_smc1+2
|
||||
|
||||
|
||||
ldx #0 ; X is pointer offset
|
||||
stx CURRENT_ROW ; actual row
|
||||
|
||||
ldx #2
|
||||
|
||||
hgr_big_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
|
||||
|
||||
big_sprite_inner_loop:
|
||||
|
||||
|
||||
big_sprite_smc1:
|
||||
lda $f000,X ; load sprite data
|
||||
beq big_sprite_transparent
|
||||
sta (GBASL),Y ; store to screen
|
||||
|
||||
big_sprite_transparent:
|
||||
inx ; increment sprite offset
|
||||
|
||||
; if > 1 page
|
||||
bne big_sprite_no_page_cross
|
||||
inc big_sprite_smc1+2
|
||||
|
||||
big_sprite_no_page_cross:
|
||||
iny ; increment output position
|
||||
|
||||
|
||||
big_sprite_width_end_smc:
|
||||
cpy #6 ; see if reached end of row
|
||||
bne big_sprite_inner_loop ; if not, loop
|
||||
|
||||
|
||||
inc CURRENT_ROW ; row
|
||||
lda CURRENT_ROW ; row
|
||||
|
||||
big_sprite_ysize_smc:
|
||||
cmp #31 ; see if at end
|
||||
bne hgr_big_sprite_yloop ; if not, loop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
hgr_draw_sprite_big_odd:
|
||||
ldy #0
|
||||
lda (INL),Y ; load xsize
|
||||
clc
|
||||
adc SPRITE_X
|
||||
sta osprite_width_end_smc+1 ; self modify for end of line
|
||||
|
||||
iny ; load ysize
|
||||
lda (INL),Y
|
||||
sta osprite_ysize_smc+1 ; self modify
|
||||
|
||||
; point smc to sprite
|
||||
lda INL ; 16-bit add
|
||||
sta osprite_smc1+1
|
||||
lda INH
|
||||
sta osprite_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
|
||||
|
||||
clc
|
||||
php ; store 0 carry on stack
|
||||
|
||||
osprite_inner_loop:
|
||||
|
||||
|
||||
osprite_smc1:
|
||||
lda $f000,X ; load sprite data
|
||||
|
||||
bne osprite_not_transparent
|
||||
|
||||
; we can't just skip if 0 because we might shift a bit in
|
||||
; from previous byte
|
||||
|
||||
plp
|
||||
bcs osprite_oops
|
||||
clc
|
||||
php
|
||||
bcc osprite_transparent_done
|
||||
|
||||
osprite_not_transparent:
|
||||
plp ; restore carry from last
|
||||
osprite_oops:
|
||||
rol ; rotate in carry
|
||||
asl ; one more time, bit6 in carry
|
||||
php ; save on stack
|
||||
sec ; assume blur/orange
|
||||
ror ; rotate it back down
|
||||
|
||||
sta (GBASL),Y ; store to screen
|
||||
|
||||
|
||||
osprite_transparent_done:
|
||||
inx ; increment sprite offset
|
||||
|
||||
; if > 1 page
|
||||
bne osprite_no_page_cross
|
||||
inc osprite_smc1+2
|
||||
|
||||
osprite_no_page_cross:
|
||||
|
||||
iny ; increment output position
|
||||
|
||||
|
||||
|
||||
osprite_width_end_smc:
|
||||
cpy #6 ; see if reached end of row
|
||||
bne osprite_inner_loop ; if not, loop
|
||||
|
||||
|
||||
plp ; restore stack
|
||||
|
||||
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
|
||||
|
102
demos/trogdor/hgr_sprite_big_mask.s
Normal file
102
demos/trogdor/hgr_sprite_big_mask.s
Normal file
@ -0,0 +1,102 @@
|
||||
;===========================================
|
||||
; hgr draw sprite (only at 14-bit boundaries)
|
||||
;===========================================
|
||||
; can handle sprites bigger than a 256 byte page
|
||||
|
||||
; flames are 8x142 or so
|
||||
|
||||
; SPRITE in INL/INH
|
||||
; MASK in MASKL/MASKH
|
||||
|
||||
; Location at SPRITE_X SPRITE_Y
|
||||
|
||||
; xsize, ysize in first two bytes
|
||||
|
||||
hgr_draw_sprite_big_mask:
|
||||
; lda SPRITE_X
|
||||
|
||||
ldy #0
|
||||
lda (INL),Y ; load xsize
|
||||
clc
|
||||
adc SPRITE_X
|
||||
sta big_sprite_width_end_smc+1 ; self modify for end of line
|
||||
|
||||
iny ; load ysize
|
||||
lda (INL),Y
|
||||
sta big_sprite_ysize_smc+1 ; self modify
|
||||
|
||||
; point smc to sprite
|
||||
lda INL ; 16-bit add
|
||||
sta big_sprite_smc1+1
|
||||
lda INH
|
||||
sta big_sprite_smc1+2
|
||||
|
||||
; point to mask
|
||||
lda MASKL
|
||||
sta big_sprite_mask_smc1+1
|
||||
lda MASKH
|
||||
sta big_sprite_mask_smc1+2
|
||||
|
||||
ldx #0 ; X is pointer offset
|
||||
stx CURRENT_ROW ; actual row
|
||||
|
||||
ldx #2
|
||||
|
||||
hgr_big_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
|
||||
|
||||
big_sprite_inner_loop:
|
||||
|
||||
|
||||
lda (GBASL),Y
|
||||
big_sprite_mask_smc1:
|
||||
and $f000,X
|
||||
|
||||
big_sprite_smc1:
|
||||
ora $f000,X ; load sprite data
|
||||
|
||||
sta (GBASL),Y ; store to screen
|
||||
|
||||
inx ; increment sprite offset
|
||||
|
||||
; if > 1 page
|
||||
bne big_sprite_no_page_cross
|
||||
inc big_sprite_smc1+2
|
||||
inc big_sprite_mask_smc1+2
|
||||
|
||||
big_sprite_no_page_cross:
|
||||
iny ; increment output position
|
||||
|
||||
|
||||
big_sprite_width_end_smc:
|
||||
cpy #6 ; see if reached end of row
|
||||
bne big_sprite_inner_loop ; if not, loop
|
||||
|
||||
|
||||
inc CURRENT_ROW ; row
|
||||
lda CURRENT_ROW ; row
|
||||
|
||||
big_sprite_ysize_smc:
|
||||
cmp #31 ; see if at end
|
||||
bne hgr_big_sprite_yloop ; if not, loop
|
||||
|
||||
rts
|
||||
|
||||
|
@ -178,7 +178,7 @@ sector_array:
|
||||
.byte 0,0,0 ; MUSIC, TROGDOR, TITLE
|
||||
|
||||
length_array:
|
||||
.byte 32,32 ; MUSIC, TROGDOR, TITLE
|
||||
.byte 32,64,32 ; MUSIC, TROGDOR, TITLE
|
||||
|
||||
PT3_ENABLE_APPLE_IIC = 1
|
||||
|
||||
|
@ -24,6 +24,9 @@ trogdor_main:
|
||||
; draw opening scene
|
||||
;======================================
|
||||
|
||||
lda #$0
|
||||
sta DRAW_PAGE
|
||||
|
||||
lda #<trog00_graphics
|
||||
sta zx_src_l+1
|
||||
lda #>trog00_graphics
|
||||
@ -36,6 +39,48 @@ trogdor_main:
|
||||
bit FULLGR
|
||||
bit PAGE1
|
||||
|
||||
jsr wait_until_keypress
|
||||
|
||||
; draw left flame
|
||||
|
||||
lda #<left_flame_small
|
||||
sta INL
|
||||
lda #>left_flame_small
|
||||
sta INH
|
||||
lda #<left_flame_small_mask
|
||||
sta MASKL
|
||||
lda #>left_flame_small_mask
|
||||
sta MASKH
|
||||
|
||||
lda #8
|
||||
sta SPRITE_X
|
||||
|
||||
lda #152
|
||||
sta SPRITE_Y
|
||||
|
||||
jsr hgr_draw_sprite_big_mask
|
||||
|
||||
; draw right flame
|
||||
|
||||
lda #<right_flame_big
|
||||
sta INL
|
||||
lda #>right_flame_big
|
||||
sta INH
|
||||
lda #<right_flame_big_mask
|
||||
sta MASKL
|
||||
lda #>right_flame_big_mask
|
||||
sta MASKH
|
||||
|
||||
lda #24
|
||||
sta SPRITE_X
|
||||
|
||||
lda #54
|
||||
sta SPRITE_Y
|
||||
|
||||
jsr hgr_draw_sprite_big_mask
|
||||
|
||||
|
||||
|
||||
jsr wait_until_keypress
|
||||
|
||||
; second
|
||||
@ -83,3 +128,9 @@ trog03_graphics:
|
||||
.include "irq_wait.s"
|
||||
|
||||
|
||||
hposn_low = $1e00
|
||||
hposn_high = $1f00
|
||||
|
||||
.include "hgr_sprite_big_mask.s"
|
||||
|
||||
.include "graphics/flame_sprites.inc"
|
||||
|
@ -127,94 +127,12 @@ MASKL = $EC ; gr_putsprite_mask
|
||||
MASKH = $ED
|
||||
FRAME = $EE
|
||||
|
||||
;==============================================
|
||||
; $F0-$FB can re-use in each file
|
||||
;==============================================
|
||||
|
||||
; tunnel
|
||||
XX = $F2
|
||||
MINUSXX = $F3
|
||||
YY = $F4
|
||||
MINUSYY = $F5
|
||||
D = $F6
|
||||
R = $F7
|
||||
CX = $F8
|
||||
CY = $F9
|
||||
RR = $FA
|
||||
|
||||
; Credits
|
||||
BACKUP_OUTL = $F2
|
||||
BACKUP_OUTH = $F3
|
||||
|
||||
; Nuts/ opener
|
||||
; local
|
||||
|
||||
SPRITE_Y = $F2
|
||||
SPRITE_X = $F3
|
||||
CURRENT_ROW = $F4
|
||||
|
||||
; PLASMACUBE
|
||||
OUT1 = $F0
|
||||
OUT1H = $F1
|
||||
OUT2 = $F2
|
||||
OUT2H = $F3
|
||||
COMPT1 = $F4
|
||||
COMPT2 = $F5
|
||||
PARAM1 = $F6
|
||||
PARAM2 = $F7
|
||||
PARAM3 = $F8
|
||||
PARAM4 = $F9
|
||||
GRLINE = $FA
|
||||
GRLINEH = $FB
|
||||
|
||||
; PLASMA
|
||||
|
||||
; CUBE
|
||||
SAVEX = $F3
|
||||
SAVEY = $F4
|
||||
SUM = $F5
|
||||
|
||||
; CIRCLES/DRAW_BOXES
|
||||
COLOR2 = $F3
|
||||
X1 = $F4
|
||||
X2 = $F5
|
||||
Y1 = $F6
|
||||
Y2 = $F7
|
||||
SCENE_COUNT = $F8
|
||||
LAST_TYPE = $F9
|
||||
|
||||
; lens
|
||||
LENS_X = $F0
|
||||
LENS_Y = $F1
|
||||
XADD = $F2
|
||||
YADD = $F3
|
||||
|
||||
; rotozoom
|
||||
NUM1L = $F0
|
||||
NUM1H = $F1
|
||||
NUM2L = $F2
|
||||
NUM2H = $F3
|
||||
RESULT = $F4 ; F5,F6,F7
|
||||
SCALE_I = $F8
|
||||
SCALE_F = $F9
|
||||
ANGLE = $FA
|
||||
|
||||
; credits
|
||||
SCROLL_X = $F0
|
||||
|
||||
; polar
|
||||
SCROLL_START = $F0
|
||||
YDEST = $F1
|
||||
|
||||
|
||||
; hgr_copy
|
||||
HGR_COPY_Y1 = $F1
|
||||
HGR_COPY_Y2 = $F2
|
||||
FIRE_COLOR = $F3
|
||||
|
||||
SCROLL_LENGTH = $F4
|
||||
OFFSET = $F5
|
||||
TREE_COUNT = $F6
|
||||
|
||||
|
||||
;==============================================
|
||||
; $FC-$FF we use for in/out pointers
|
||||
|
Loading…
x
Reference in New Issue
Block a user