parent
dbc71d4086
commit
67c80ee430
|
@ -22,7 +22,8 @@ HELLO: hello.bas
|
|||
SPRITE: sprite.o
|
||||
ld65 -o SPRITE sprite.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
|
||||
|
||||
sprite.o: sprite.s graphics/graphics.inc
|
||||
sprite.o: sprite.s graphics/graphics.inc hand_sprites.inc \
|
||||
hgr_14x14_sprite.s
|
||||
ca65 -o sprite.o sprite.s -l sprite.lst
|
||||
|
||||
###
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
;===============
|
||||
; point sprite
|
||||
;===============
|
||||
|
||||
point_sprite_l: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $63 ; 0 110 0 011
|
||||
.byte $66 ; 0 110 0 110
|
||||
.byte $2c ; 0 010 1 100
|
||||
.byte $6c ; 0 110 1 100
|
||||
.byte $78 ; 0 111 1 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
|
||||
point_sprite_r: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $0A ; 0 000 1 010
|
||||
.byte $2A ; 0 010 1 010
|
||||
.byte $2D ; 0 010 1 101
|
||||
.byte $37 ; 0 011 0 111
|
||||
.byte $3F ; 0 011 1 111
|
||||
.byte $3F ; 0 011 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
|
||||
point_mask_l: ; X 654 3 210
|
||||
.byte $9f ; 1 001 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $88 ; 1 000 1 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $83 ; 1 000 0 011
|
||||
.byte $87 ; 1 000 0 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
|
||||
point_mask_r: ; X 654 3 210
|
||||
.byte $ff ; 1 111 1 111
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $e0 ; 1 110 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $c0 ; 1 100 0 000
|
||||
.byte $c0 ; 1 100 0 000
|
||||
|
||||
|
||||
|
||||
;===============
|
||||
; grab sprite
|
||||
;===============
|
||||
|
||||
grab_sprite_l: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $4c ; 0 100 1 100
|
||||
.byte $4c ; 0 100 1 100
|
||||
.byte $58 ; 0 101 1 000
|
||||
.byte $58 ; 0 101 1 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $73 ; 0 111 0 011
|
||||
.byte $77 ; 0 111 0 111
|
||||
.byte $7e ; 0 111 1 110
|
||||
.byte $7c ; 0 111 1 100
|
||||
.byte $7c ; 0 111 1 100
|
||||
.byte $78 ; 0 111 1 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
|
||||
grab_sprite_r: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $0d ; 0 000 1 101
|
||||
.byte $0d ; 0 000 1 101
|
||||
.byte $0d ; 0 000 1 101
|
||||
.byte $6d ; 0 110 1 101
|
||||
.byte $6f ; 0 110 1 111
|
||||
.byte $7f ; 0 111 1 111
|
||||
.byte $3f ; 0 011 1 111
|
||||
.byte $3f ; 0 011 1 111
|
||||
.byte $3f ; 0 011 1 111
|
||||
.byte $1f ; 0 001 1 111
|
||||
.byte $1f ; 0 001 1 111
|
||||
.byte $0f ; 0 000 1 111
|
||||
.byte $0f ; 0 000 1 111
|
||||
|
||||
grab_mask_l: ; X 654 3 210
|
||||
.byte $b3 ; 1 011 0 011
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $83 ; 1 000 0 011
|
||||
.byte $83 ; 1 000 0 011
|
||||
.byte $84 ; 1 000 0 100
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $83 ; 1 000 0 011
|
||||
.byte $c7 ; 1 100 0 111
|
||||
.byte $c7 ; 1 100 1 111
|
||||
|
||||
grab_mask_r: ; X 654 3 210
|
||||
.byte $f2 ; 1 111 0 010
|
||||
.byte $e0 ; 1 110 0 000
|
||||
.byte $e0 ; 1 110 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 100 0 000
|
||||
.byte $c0 ; 1 100 0 000
|
||||
.byte $e0 ; 1 110 0 000
|
||||
.byte $e0 ; 1 110 0 000
|
||||
|
||||
|
|
@ -0,0 +1,177 @@
|
|||
|
||||
;======================
|
||||
; hgr 14x14 draw sprite
|
||||
;======================
|
||||
; SPRITE in OUTL/OUTH
|
||||
; Location at CURSOR_X CURSOR_Y
|
||||
|
||||
; left sprite AT OUTL/OUTH
|
||||
; right sprite at OUTL/OUTH + 14
|
||||
; left mask at OUTL/OUTH + 28
|
||||
; right mask at OUTL/OUTH + 42
|
||||
|
||||
hgr_draw_sprite_14x14:
|
||||
|
||||
; set up pointers
|
||||
lda OUTL
|
||||
sta hds_smc1+1
|
||||
lda OUTH
|
||||
sta hds_smc1+2
|
||||
|
||||
clc
|
||||
lda OUTL
|
||||
adc #14
|
||||
sta hds_smc2+1
|
||||
lda OUTH
|
||||
adc #0
|
||||
sta hds_smc2+2
|
||||
|
||||
clc
|
||||
lda OUTL
|
||||
adc #28
|
||||
sta hds_smc3+1
|
||||
lda OUTH
|
||||
adc #0
|
||||
sta hds_smc3+2
|
||||
|
||||
clc
|
||||
lda OUTL
|
||||
adc #42
|
||||
sta hds_smc4+1
|
||||
lda OUTH
|
||||
adc #0
|
||||
sta hds_smc4+2
|
||||
|
||||
|
||||
ldx #0
|
||||
hgr_14x14_sprite_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc CURSOR_Y
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy CURSOR_X
|
||||
|
||||
lda (GBASL),Y
|
||||
hds_smc3:
|
||||
and point_mask_l,X
|
||||
hds_smc1:
|
||||
ora point_sprite_l,X
|
||||
sta (GBASL),Y
|
||||
|
||||
iny
|
||||
|
||||
lda (GBASL),Y
|
||||
hds_smc4:
|
||||
and point_mask_r,X
|
||||
hds_smc2:
|
||||
ora point_sprite_r,X
|
||||
sta (GBASL),Y
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne hgr_14x14_sprite_yloop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;======================
|
||||
; save bg 14x14
|
||||
;======================
|
||||
|
||||
save_bg_14x14:
|
||||
|
||||
ldx #0
|
||||
save_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc CURSOR_Y
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy CURSOR_X
|
||||
|
||||
lda (GBASL),Y
|
||||
sta save_left_14x14,X
|
||||
|
||||
iny
|
||||
|
||||
lda (GBASL),Y
|
||||
sta save_right_14x14,X
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne save_yloop
|
||||
|
||||
rts
|
||||
|
||||
;======================
|
||||
; restore bg 14x14
|
||||
;======================
|
||||
|
||||
restore_bg_14x14:
|
||||
|
||||
ldx #0
|
||||
restore_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc CURSOR_Y
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy CURSOR_X
|
||||
|
||||
lda save_left_14x14,X
|
||||
sta (GBASL),Y
|
||||
|
||||
iny
|
||||
|
||||
lda save_right_14x14,X
|
||||
sta (GBASL),Y
|
||||
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne restore_yloop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
;====================
|
||||
; save area
|
||||
;====================
|
||||
|
||||
save_right_14x14:
|
||||
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
save_left_14x14:
|
||||
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
|
@ -1,19 +1,26 @@
|
|||
|
||||
.include "hardware.inc"
|
||||
|
||||
XX = $00
|
||||
YY = $01
|
||||
CURSOR_X = $62
|
||||
CURSOR_Y = $63
|
||||
NIBCOUNT = $09
|
||||
|
||||
GBASL = $26
|
||||
GBASH = $27
|
||||
|
||||
WHICH = $FD
|
||||
OUTL = $FE
|
||||
OUTH = $FF
|
||||
|
||||
sprite_test:
|
||||
|
||||
jsr HGR ; Hi-res graphics
|
||||
bit FULLGR ; full screen
|
||||
|
||||
|
||||
lda #0
|
||||
sta WHICH
|
||||
|
||||
lda #<(mona_lzsa)
|
||||
sta getsrc_smc+1
|
||||
lda #>(mona_lzsa)
|
||||
|
@ -29,58 +36,85 @@ sprite_test:
|
|||
; sprite stuff
|
||||
|
||||
lda #10
|
||||
sta XX
|
||||
sta CURSOR_X
|
||||
lda #10
|
||||
sta YY
|
||||
sta CURSOR_Y
|
||||
|
||||
forever:
|
||||
jsr save_bg ; save bg
|
||||
jsr save_bg_14x14 ; save bg
|
||||
|
||||
jsr draw_sprite ; draw sprite
|
||||
lda WHICH
|
||||
bne do_grab
|
||||
|
||||
do_point:
|
||||
lda #<point_sprite_l
|
||||
sta OUTL
|
||||
lda #>point_sprite_l
|
||||
jmp done_select
|
||||
do_grab:
|
||||
|
||||
lda #<grab_sprite_l
|
||||
sta OUTL
|
||||
lda #>grab_sprite_l
|
||||
|
||||
done_select:
|
||||
sta OUTH
|
||||
|
||||
jsr hgr_draw_sprite_14x14 ; draw sprite
|
||||
|
||||
keyloop:
|
||||
lda KEYPRESS
|
||||
bpl keyloop
|
||||
|
||||
pha
|
||||
jsr restore_bg ; restore bg
|
||||
jsr restore_bg_14x14 ; restore bg
|
||||
pla
|
||||
|
||||
check_right:
|
||||
cmp #'D'|$80
|
||||
bne check_left
|
||||
|
||||
inc XX
|
||||
inc CURSOR_X
|
||||
jmp done_key
|
||||
|
||||
check_left:
|
||||
cmp #'A'|$80
|
||||
bne check_up
|
||||
|
||||
dec XX
|
||||
dec CURSOR_X
|
||||
jmp done_key
|
||||
|
||||
check_up:
|
||||
cmp #'W'|$80
|
||||
bne check_down
|
||||
|
||||
dec YY
|
||||
dec YY
|
||||
dec YY
|
||||
dec YY
|
||||
dec YY
|
||||
dec CURSOR_Y
|
||||
dec CURSOR_Y
|
||||
dec CURSOR_Y
|
||||
dec CURSOR_Y
|
||||
dec CURSOR_Y
|
||||
|
||||
jmp done_key
|
||||
|
||||
check_down:
|
||||
cmp #'S'|$80
|
||||
bne check_space
|
||||
|
||||
inc CURSOR_Y
|
||||
inc CURSOR_Y
|
||||
inc CURSOR_Y
|
||||
inc CURSOR_Y
|
||||
inc CURSOR_Y
|
||||
|
||||
jmp done_key
|
||||
|
||||
check_space:
|
||||
cmp #' '|$80
|
||||
bne done_key
|
||||
|
||||
inc YY
|
||||
inc YY
|
||||
inc YY
|
||||
inc YY
|
||||
inc YY
|
||||
lda WHICH
|
||||
eor #$1
|
||||
sta WHICH
|
||||
|
||||
jmp done_key
|
||||
|
||||
|
@ -91,206 +125,10 @@ nokey:
|
|||
jmp forever
|
||||
|
||||
|
||||
;======================
|
||||
; draw sprite
|
||||
;======================
|
||||
|
||||
draw_sprite:
|
||||
|
||||
ldx #0
|
||||
sprite_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc YY
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy XX
|
||||
|
||||
lda (GBASL),Y
|
||||
and hand_mask_l,X
|
||||
ora hand_sprite_l,X
|
||||
sta (GBASL),Y
|
||||
|
||||
iny
|
||||
|
||||
lda (GBASL),Y
|
||||
and hand_mask_r,X
|
||||
ora hand_sprite_r,X
|
||||
sta (GBASL),Y
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne sprite_yloop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;======================
|
||||
; save bg
|
||||
;======================
|
||||
|
||||
save_bg:
|
||||
|
||||
ldx #0
|
||||
save_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc YY
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy XX
|
||||
|
||||
lda (GBASL),Y
|
||||
sta save_left,X
|
||||
|
||||
iny
|
||||
|
||||
lda (GBASL),Y
|
||||
sta save_right,X
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne save_yloop
|
||||
|
||||
rts
|
||||
|
||||
;======================
|
||||
; restore bg
|
||||
;======================
|
||||
|
||||
restore_bg:
|
||||
|
||||
ldx #0
|
||||
restore_yloop:
|
||||
txa
|
||||
pha
|
||||
|
||||
clc
|
||||
adc YY
|
||||
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
; calc GBASL/GBASH
|
||||
jsr HPOSN ; (Y,X),(A) (values stored in HGRX,XH,Y)
|
||||
|
||||
pla
|
||||
tax
|
||||
|
||||
ldy XX
|
||||
|
||||
lda save_left,X
|
||||
sta (GBASL),Y
|
||||
|
||||
iny
|
||||
|
||||
lda save_right,X
|
||||
sta (GBASL),Y
|
||||
|
||||
|
||||
inx
|
||||
cpx #14
|
||||
bne restore_yloop
|
||||
|
||||
rts
|
||||
|
||||
|
||||
.include "hgr_14x14_sprite.s"
|
||||
|
||||
.include "decompress_fast_v2.s"
|
||||
|
||||
.include "graphics/graphics.inc"
|
||||
|
||||
|
||||
; hand sprite
|
||||
|
||||
hand_mask_l: ; X 654 3 210
|
||||
.byte $9f ; 1 001 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $88 ; 1 000 1 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $81 ; 1 000 0 001
|
||||
.byte $83 ; 1 000 0 011
|
||||
.byte $87 ; 1 000 0 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
.byte $8f ; 1 000 1 111
|
||||
|
||||
hand_sprite_l: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $63 ; 0 110 0 011
|
||||
.byte $66 ; 0 110 0 110
|
||||
.byte $2c ; 0 010 1 100
|
||||
.byte $6c ; 0 110 1 100
|
||||
.byte $78 ; 0 111 1 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $70 ; 0 111 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
.byte $60 ; 0 110 0 000
|
||||
|
||||
hand_mask_r: ; X 654 3 210
|
||||
.byte $ff ; 1 111 1 111
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $fe ; 1 111 1 110
|
||||
.byte $e0 ; 1 110 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $80 ; 1 000 0 000
|
||||
.byte $c0 ; 1 100 0 000
|
||||
.byte $c0 ; 1 100 0 000
|
||||
|
||||
hand_sprite_r: ; X 654 3 210
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $00 ; 0 000 0 000
|
||||
.byte $0A ; 0 000 1 010
|
||||
.byte $2A ; 0 010 1 010
|
||||
.byte $2D ; 0 010 1 101
|
||||
.byte $37 ; 0 011 0 111
|
||||
.byte $3F ; 0 011 1 111
|
||||
.byte $3F ; 0 011 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
.byte $1F ; 0 001 1 111
|
||||
|
||||
|
||||
save_right:
|
||||
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||
|
||||
save_left:
|
||||
.byte $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
|
||||
.include "hand_sprites.inc"
|
||||
|
|
Loading…
Reference in New Issue