fish: probably ill-advised

This commit is contained in:
Vince Weaver 2024-06-05 00:56:26 -04:00
parent ab2e28ee42
commit a7f1bf4212
10 changed files with 1622 additions and 2 deletions

View File

@ -12,7 +12,8 @@ all: sb.dsk
####
sb.dsk: QBOOT QLOAD TITLE DUCK_POND ROOF ASPLODE BACK_OFF TARGET ./cliff/CLIFF RAT
sb.dsk: QBOOT QLOAD TITLE DUCK_POND ROOF ASPLODE BACK_OFF TARGET \
./fish/FISH ./cliff/CLIFF RAT
cp $(EMPTY_DISK) sb.dsk
$(DOS33_RAW) sb.dsk 0 0 QBOOT 0 1
$(DOS33_RAW) sb.dsk 0 2 QBOOT 1 1
@ -20,7 +21,7 @@ sb.dsk: QBOOT QLOAD TITLE DUCK_POND ROOF ASPLODE BACK_OFF TARGET ./cliff/CLIFF R
$(DOS33_RAW) sb.dsk 1 0 QLOAD 0 0
$(DOS33_RAW) sb.dsk 2 0 TITLE 0 0
$(DOS33_RAW) sb.dsk 5 0 DUCK_POND 0 0
$(DOS33_RAW) sb.dsk 10 0 ROOF 0 0
$(DOS33_RAW) sb.dsk 10 0 ./fish/FISH 0 0
$(DOS33_RAW) sb.dsk 15 0 ASPLODE 0 0
$(DOS33_RAW) sb.dsk 20 0 TARGET 0 0
$(DOS33_RAW) sb.dsk 25 0 ./cliff/CLIFF 0 0
@ -100,6 +101,12 @@ back_off.o: back_off.s zx02_optim.s \
./cliff/CLIFF:
cd cliff && make
####
./fish/FISH:
cd fish && make
#CLIFF: cliff.o
# ld65 -o CLIFF cliff.o -C $(LINKER_SCRIPTS)/apple2_6000.inc

38
games/sb/fish/Makefile Normal file
View File

@ -0,0 +1,38 @@
include ../../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02
PNG_TO_HGR = ../../../utils/hgr-utils/png2hgr
LINKER_SCRIPTS = ../../../linker_scripts
all: FISH
####
FISH: fish.o
ld65 -o FISH fish.o -C $(LINKER_SCRIPTS)/apple2_6000.inc
fish.o: fish.s zx02_optim.s \
zp.inc hardware.inc
ca65 -o fish.o fish.s -l fish.lst
# fish_graphics/sb_title.hgr.zx02 \
# fish_graphics/sb_zone.hgr.zx02 \
# fish_graphics/sb_sprites.inc \
# fish_sound/fish_sound.btc.zx02 \
# audio.s play_fish.s fish_head.s \
# hgr_sprite_big.s cycle_colors.s \
#graphics/sb_sprites.inc:
# cd fish_graphics && make
#graphics/sb_title.hgr.zx02:
# cd fish_graphics && make
#sound/fish.btc.zx02:
# cd fish_sound && make
clean:
rm -f *.lst *.o FISH

775
games/sb/fish/fish.s Normal file
View File

@ -0,0 +1,775 @@
; Fishing Challenge '91
;
; Yet Another HR project
;
; by deater (Vince Weaver) <vince@deater.net>
.include "zp.inc"
.include "hardware.inc"
div7_table = $400
mod7_table = $500
hposn_high = $600
hposn_low = $700
fish_start:
;===================
; set graphics mode
;===================
jsr HOME
bit HIRES
bit FULLGR
bit SET_GR
bit PAGE1
;====================
; set up tables
;====================
lda #$20
sta HGR_PAGE
jsr hgr_make_tables
.if 0
;==========================
; Load Sound
;===========================
lda SOUND_STATUS
and #SOUND_IN_LC
beq done_load_sound
; read/write RAM, use $d000 bank1
bit $C083
bit $C083
lda #<sound_data
sta ZX0_src
lda #>sound_data
sta ZX0_src+1
lda #$D0
jsr full_decomp
; read ROM/no-write
bit $C082
done_load_sound:
.endif
;==========================
; Load Title
;===========================
load_title:
lda #<title_data
sta ZX0_src
lda #>title_data
sta ZX0_src+1
lda #$20
jsr full_decomp
wait_at_tile:
lda KEYPRESS
bpl wait_at_tile
bit KEYRESET
.if 0
;===================
; setup game
;===================
;==========================
; Load Backgrounds
;===========================
; this is tricky as there's not enough room
; so we are over-writing stuff carefully
load_backgrounds:
lda #<bg2_data
sta ZX0_src
lda #>bg2_data
sta ZX0_src+1
lda #$A0
jsr full_decomp
lda #<bg1_data
sta ZX0_src
lda #>bg1_data
sta ZX0_src+1
lda #$80
jsr full_decomp
;===================
; set up variables
lda #16
sta STRONGBAD_X
sta PLAYER_X
lda #1
sta STRONGBAD_DIR
sta BULLET_YDIR
lda #SHIELD_DOWN
sta SHIELD_POSITION
sta SHIELD_COUNT
lda #0
sta BULLET_X_L
sta BULLET_X_VEL
sta HEAD_DAMAGE
lda #$80
sta BULLET_X_VEL_L
lda #20
sta BULLET_X
lda #0
sta BULLET_Y
jmp main_loop
; start at least 8k in?
;==========================
; main loop
;===========================
main_loop:
jsr flip_page
;========================
; copy over background
;========================
reset_loop:
lda FRAME
and #$2
beq odd_bg
even_bg:
lda #$A0
bne do_bg
odd_bg:
lda #$80
do_bg:
jsr hgr_copy
inc FRAME
;==========================
; adjust shield
;==========================
lda SHIELD_COUNT
beq done_shield_count
dec SHIELD_COUNT
bne done_shield_count
lda #SHIELD_DOWN ; put shield down if timeout
sta SHIELD_POSITION
done_shield_count:
;===========================
; move head
;===========================
lda FRAME
and #$3
bne no_move_head
lda STRONGBAD_X
cmp #21
bcs reverse_head_dir
cmp #12
bcs no_reverse_head_dir
reverse_head_dir:
lda STRONGBAD_DIR
eor #$FF
sta STRONGBAD_DIR
inc STRONGBAD_DIR
no_reverse_head_dir:
clc
lda STRONGBAD_X
adc STRONGBAD_DIR
sta STRONGBAD_X
no_move_head:
;==========================
; draw head
;===========================
ldx HEAD_DAMAGE
lda head_sprites_l,X
sta INL
lda head_sprites_h,X
sta INH
lda STRONGBAD_X
sta SPRITE_X
lda #36
sta SPRITE_Y
jsr hgr_draw_sprite_big
;==========================
; move bullet
;===========================
; 16 bit add
clc
lda BULLET_X_L
adc BULLET_X_VEL_L
sta BULLET_X_L
lda BULLET_X
adc BULLET_X_VEL
sta BULLET_X
;========================
; bounce off "walls"
; in reality just bounce if <9 or > 29?
lda BULLET_X
cmp #29
bcs walls_out ; bge
cmp #9
bcs walls_good ; bge
walls_out:
; flip X direction
sec
lda #0
sbc BULLET_X_VEL_L
sta BULLET_X_VEL_L
lda #0
sbc BULLET_X_VEL
sta BULLET_X_VEL
walls_good:
; move bullet Y
lda BULLET_YDIR
bne bullet_down
bullet_up:
dec BULLET_Y
jmp bullet_y_done
bullet_down:
inc BULLET_Y
bullet_y_done:
; see if off end
lda BULLET_Y
cmp #17
bcc bullet_still_good
; reset to top
lda #0
sta BULLET_Y
bullet_still_good:
;==========================
; check bullet collisions
;===========================
;===========================
; check player
; if (bullet_x > player_x+2) &&
; (bullet_x<player_x+6)
; if 2 < bx - px < 6 ???
; 012345678
; b-p
; --------
; 8765432101234567890123456
; p-b ----------------
; 8765432101234567890123456
; NNNNNNNNNNYYYYNNNNNNNNNNN
; XXXXXXXXPPOOOOPPXXXXXXXXX
; only if BULLET_Y=16?
lda BULLET_Y
cmp #16
bne skip_check_player_collide
check_player_collide:
sec
lda BULLET_X
sbc PLAYER_X
cmp #2
bcc skip_check_player_collide ; blt
cmp #8
bcs skip_check_player_collide
jmp asplode_asplode
skip_check_player_collide:
;===========================
; check shield collide
; only if Y=15 and YDIR=1
check_shield_collide:
lda BULLET_Y
cmp #15
beq do_check_shields
jmp skip_check_shield_collide
do_check_shields:
; sorta-random number in X
ldx FRAME
lda $6000,X ; from source code
and #$3
tax
lda SHIELD_POSITION
beq skip_check_shield_collide ; 0 means DOWN
shields_up:
; our rules
; SHIELD_X_VEL maxes at 1/-1
; hitting shield left subs random $10/$20/$20/$40
; hitting shield right adds random $10/$20/$20/$40
; hitting shield center adds/subs random $10/$20
cmp #SHIELD_UP_RIGHT
beq check_hit_shield_right
cmp #SHIELD_UP_CENTER
beq check_hit_shield_center
check_hit_shield_left:
sec
lda BULLET_X
sbc PLAYER_X
cmp #1
bcc skip_check_shield_collide ; blt
cmp #7
bcs skip_check_shield_collide ; bge
hit_shield_left:
sec
lda BULLET_X_VEL_L
sbc bullet_vals,X
sta BULLET_X_VEL_L
lda BULLET_X_VEL
sbc #0
sta BULLET_X_VEL
jmp done_hit_shield
check_hit_shield_right:
sec
lda BULLET_X
sbc PLAYER_X
cmp #4
bcc skip_check_shield_collide ; blt
cmp #10
bcs skip_check_shield_collide
hit_shield_right:
clc
lda BULLET_X_VEL_L
adc bullet_vals,X
sta BULLET_X_VEL_L
lda BULLET_X_VEL
adc #0
sta BULLET_X_VEL
jmp done_hit_shield
check_hit_shield_center:
sec
lda BULLET_X
sbc PLAYER_X
cmp #2
bcc skip_check_shield_collide ; blt
cmp #8
bcs skip_check_shield_collide ; bge
hit_shield_center:
cpx #1
bcs center_left
clc
lda BULLET_X_VEL_L
adc bullet_vals_center,X
sta BULLET_X_VEL_L
lda BULLET_X_VEL
adc #0
sta BULLET_X_VEL
jmp done_hit_shield
center_left:
sec
lda BULLET_X_VEL_L
sbc bullet_vals_center,X
sta BULLET_X_VEL_L
lda BULLET_X_VEL
sbc #0
sta BULLET_X_VEL
; jmp done_hit_shield
done_hit_shield:
; max at $1/$00 or $FF/$00
; flip ydir
lda #0
sta BULLET_YDIR
; play sound
ldy #5
jsr play_asplode
skip_check_shield_collide:
;===========================
; check head
; only if Y=0 and YDIR=0
lda BULLET_Y
bne done_check_head
lda BULLET_YDIR
bne done_check_head
check_head_collide:
sec
lda BULLET_X
sbc STRONGBAD_X
cmp #0
bcc skip_check_head_collide ; blt
cmp #6
bcs skip_check_head_collide
inc HEAD_DAMAGE ; increase head damage
lda HEAD_DAMAGE
cmp #5
bcc skip_check_head_collide
lda #0 ; reset
sta HEAD_DAMAGE
skip_check_head_collide:
lda #1
sta BULLET_YDIR ; bounce
done_check_head:
;=====================
; play bullet sound
; if Y=1 and YDIR=1
lda BULLET_Y
cmp #1
bne no_ysound
lda BULLET_YDIR
beq no_ysound
ldy #6
jsr play_asplode
no_ysound:
;==========================
; draw bullet
;===========================
ldy BULLET_Y
lda bullet_sprite_l,Y
sta INL
lda bullet_sprite_h,Y
sta INH
lda BULLET_X
sta SPRITE_X
lda bullet_sprite_y,Y
sta SPRITE_Y
jsr hgr_draw_sprite_big
;==========================
; draw player
;===========================
ldx SHIELD_POSITION
lda shield_sprites_l,X
sta INL
lda shield_sprites_h,X
sta INH
lda PLAYER_X
sta SPRITE_X
lda #138
sta SPRITE_Y
jsr hgr_draw_sprite_big
check_keypress:
lda KEYPRESS
bpl done_keyboard_check
bit KEYRESET ; clear the keyboard strobe
; clear high bit
and #$7f
and #$df ; convert lowercase to upper
; cmp #'Q'
; beq done_game
cmp #27 ; escape
beq done_game
cmp #'A' ; shield left
beq shield_left
cmp #'S' ; shield center
beq shield_center
cmp #'D' ; shield right
beq shield_right
cmp #'O'
beq back_off
cmp #8 ; left
beq move_left
cmp #$15
beq move_right ; right
done_keyboard_check:
jmp main_loop
move_left:
lda PLAYER_X
beq no_more_left
dec PLAYER_X
no_more_left:
jmp main_loop
move_right:
lda PLAYER_X
cmp #28 ; bge
bcs no_more_right
inc PLAYER_X
no_more_right:
jmp main_loop
shield_left:
lda SHIELD_POSITION
bne done_adjust_shield
lda #SHIELD_UP_LEFT
bne adjust_shield
shield_center:
lda SHIELD_POSITION
bne done_adjust_shield
lda #SHIELD_UP_CENTER
bne adjust_shield
shield_right:
lda SHIELD_POSITION
bne done_adjust_shield
lda #SHIELD_UP_RIGHT
adjust_shield:
sta SHIELD_POSITION
lda #4
sta SHIELD_COUNT
done_adjust_shield:
jmp main_loop
asplode_asplode:
jsr do_asplode
jmp reset_loop
back_off:
lda #7
bne really_done_game ; bra
;==========================
; done game
;==========================
done_game:
lda #0
really_done_game:
sta WHICH_LOAD
rts
wait_until_keypress:
lda KEYPRESS ; 4
bpl wait_until_keypress ; 3
bit KEYRESET ; clear the keyboard buffer
rts
.include "asplode_head.s"
;==========
; flip page
;==========
flip_page:
lda DRAW_PAGE
beq draw_page2
draw_page1:
bit PAGE2
lda #0
beq done_flip
draw_page2:
bit PAGE1
lda #$20
done_flip:
sta DRAW_PAGE
rts
.endif
title_data:
.incbin "graphics/fish_title.hgr.zx02"
;bg1_data:
; .incbin "asplode_graphics/sb_zone.hgr.zx02"
;sound_data:
; .incbin "asplode_sound/asplode_sound.btc.zx02"
.include "hgr_tables.s"
.include "zx02_optim.s"
.include "hgr_sprite_big.s"
.include "hgr_copy_fast.s"
; .include "audio.s"
; .include "play_asplode.s"
; .include "asplode_graphics/sb_sprites.inc"
.if 0
shield_sprites_l:
.byte <player_sprite,<shield_left_sprite
.byte <shield_center_sprite,<shield_right_sprite
shield_sprites_h:
.byte >player_sprite,>shield_left_sprite
.byte >shield_center_sprite,>shield_right_sprite
head_sprites_l:
.byte <big_head0_sprite,<big_head1_sprite,<big_head2_sprite
.byte <big_head3_sprite,<big_head4_sprite
head_sprites_h:
.byte >big_head0_sprite,>big_head1_sprite,>big_head2_sprite
.byte >big_head3_sprite,>big_head4_sprite
y_positions:
; 90 to 160 roughly? Let's say 64?
; have 16 positions? 4 each?
; can probably optimize this
bullet_sprite_l:
.byte <bullet0_sprite, <bullet1_sprite, <bullet2_sprite, <bullet3_sprite
.byte <bullet4_sprite, <bullet5_sprite, <bullet6_sprite, <bullet7_sprite
.byte <bullet8_sprite, <bullet9_sprite,<bullet10_sprite,<bullet11_sprite
.byte <bullet12_sprite,<bullet13_sprite,<bullet14_sprite,<bullet15_sprite
.byte <bullet_done_sprite
bullet_sprite_h:
.byte >bullet0_sprite, >bullet1_sprite, >bullet2_sprite, >bullet3_sprite
.byte >bullet4_sprite, >bullet5_sprite, >bullet6_sprite, >bullet7_sprite
.byte >bullet8_sprite, >bullet9_sprite,>bullet10_sprite,>bullet11_sprite
.byte >bullet12_sprite,>bullet13_sprite,>bullet14_sprite,>bullet15_sprite
.byte >bullet_done_sprite
bullet_sprite_y:
.byte 83,88,93,98
.byte 103,108,113,118
.byte 123,128,133,138
.byte 143,148,153,158
.byte 163
bullet_vals:
.byte $10,$20,$20,$40
bullet_vals_center:
.byte $20,$00,$00,$20
; original
; 1 = 6
; 2 = 12
; 3 = 18
; 4 = 25
; 5 = 32
; 6 = 38
; 7 = 44
; 8 = 50
; 9 = 57
; 10= 63
; 11= 70
; 12= 77
; 13= 82
; 14= 89
; 15= 95
; 27= 167 (peak)
; 30= 148
; 31= 139
; 9,5 -> 22,14 = 12x9 roughly. 3 times smaller, 4x3? 2x6?
bg2_data:
.incbin "asplode_graphics/sb_zone2.hgr.zx02"
.endif

View File

@ -0,0 +1,86 @@
include ../../../../Makefile.inc
ZX02 = ~/research/6502_compression/zx02.git/build/zx02 -f
PNG_TO_HGR = ../../../../utils/hgr-utils/png2hgr
HGR_SPRITE = ../../../utils/hgr-utils/hgr_make_sprite
all: fish_title.hgr.zx02
# sb_sprites.inc
####
fish_title.hgr.zx02: fish_title.hgr
$(ZX02) fish_title.hgr fish_title.hgr.zx02
fish_title.hgr: fish_title.png
$(PNG_TO_HGR) fish_title.png > fish_title.hgr
####
# TODO: optimize these a bit
sb_sprites.inc: sb_sprites.png
$(HGR_SPRITE) -s -l big_head0_sprite sb_sprites.png 0 78 47 134 > sb_sprites.inc
$(HGR_SPRITE) -s -l big_head1_sprite sb_sprites.png 56 78 103 134 >> sb_sprites.inc
$(HGR_SPRITE) -s -l big_head2_sprite sb_sprites.png 112 78 159 134 >> sb_sprites.inc
$(HGR_SPRITE) -s -l big_head3_sprite sb_sprites.png 56 21 103 77 >> sb_sprites.inc
$(HGR_SPRITE) -s -l big_head4_sprite sb_sprites.png 112 21 159 77 >> sb_sprites.inc
$(HGR_SPRITE) -s -l player_sprite sb_sprites.png 98 138 181 192 >> sb_sprites.inc
$(HGR_SPRITE) -s -l shield_left_sprite sb_sprites.png 0 138 83 192 >> sb_sprites.inc
$(HGR_SPRITE) -s -l shield_center_sprite sb_sprites.png 196 83 279 137 >> sb_sprites.inc
$(HGR_SPRITE) -s -l shield_right_sprite sb_sprites.png 196 138 279 192 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet0_sprite sb_sprites.png 168 1 181 7 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet1_sprite sb_sprites.png 168 8 181 14 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet2_sprite sb_sprites.png 168 15 181 21 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet3_sprite sb_sprites.png 168 22 181 28 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet4_sprite sb_sprites.png 168 29 181 35 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet5_sprite sb_sprites.png 168 36 181 42 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet6_sprite sb_sprites.png 168 43 181 49 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet7_sprite sb_sprites.png 168 50 181 56 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet8_sprite sb_sprites.png 168 57 181 63 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet9_sprite sb_sprites.png 168 64 181 70 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet10_sprite sb_sprites.png 168 71 181 77 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet11_sprite sb_sprites.png 168 78 181 84 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet12_sprite sb_sprites.png 168 85 181 91 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet13_sprite sb_sprites.png 168 92 181 98 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet14_sprite sb_sprites.png 168 99 181 105 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet15_sprite sb_sprites.png 168 106 181 112 >> sb_sprites.inc
$(HGR_SPRITE) -s -l your_sprite sb_sprites.png 0 0 41 20 >> sb_sprites.inc
$(HGR_SPRITE) -s -l head_sprite sb_sprites.png 56 0 90 20 >> sb_sprites.inc
$(HGR_SPRITE) -s -l a_sprite sb_sprites.png 98 0 104 20 >> sb_sprites.inc
$(HGR_SPRITE) -s -l splode_sprite sb_sprites.png 112 0 166 20 >> sb_sprites.inc
$(HGR_SPRITE) -s -l your_med_sprite sb_sprites.png 0 22 33 31 >> sb_sprites.inc
$(HGR_SPRITE) -s -l head_med_sprite sb_sprites.png 0 32 26 41 >> sb_sprites.inc
$(HGR_SPRITE) -s -l a_med_sprite sb_sprites.png 42 32 47 41 >> sb_sprites.inc
$(HGR_SPRITE) -s -l splode_med_sprite sb_sprites.png 0 42 40 51 >> sb_sprites.inc
$(HGR_SPRITE) -s -l your_sm_sprite sb_sprites.png 0 52 19 57 >> sb_sprites.inc
$(HGR_SPRITE) -s -l head_sm_sprite sb_sprites.png 28 52 47 57 >> sb_sprites.inc
$(HGR_SPRITE) -s -l a_sm_sprite sb_sprites.png 0 58 5 63 >> sb_sprites.inc
$(HGR_SPRITE) -s -l splode_sm_sprite sb_sprites.png 14 58 33 63 >> sb_sprites.inc
$(HGR_SPRITE) -s -l bullet_done_sprite sb_sprites.png 168 114 180 123 >> sb_sprites.inc
$(HGR_SPRITE) -s -l asploding1_sprite sb_sprites.png 196 27 222 52 >> sb_sprites.inc
$(HGR_SPRITE) -s -l asploding2_sprite sb_sprites.png 238 27 264 52 >> sb_sprites.inc
$(HGR_SPRITE) -s -l asploding3_sprite sb_sprites.png 196 53 222 78 >> sb_sprites.inc
$(HGR_SPRITE) -s -l asploding4_sprite sb_sprites.png 238 53 264 78 >> sb_sprites.inc
###
bob_sprites.inc: bob_sprites.png Makefile
$(HGR_SPRITE) -s -l back_sprite bob_sprites.png 0 0 41 20 > bob_sprites.inc
$(HGR_SPRITE) -s -l off_sprite bob_sprites.png 56 0 90 20 >> bob_sprites.inc
$(HGR_SPRITE) -s -l baby_sprite bob_sprites.png 98 0 131 20 >> bob_sprites.inc
$(HGR_SPRITE) -s -l back_med_sprite bob_sprites.png 0 22 33 31 >> bob_sprites.inc
$(HGR_SPRITE) -s -l off_med_sprite bob_sprites.png 0 32 26 41 >> bob_sprites.inc
$(HGR_SPRITE) -s -l baby_med_sprite bob_sprites.png 0 42 40 51 >> bob_sprites.inc
$(HGR_SPRITE) -s -l back_sm_sprite bob_sprites.png 0 52 19 57 >> bob_sprites.inc
$(HGR_SPRITE) -s -l off_sm_sprite bob_sprites.png 28 52 47 57 >> bob_sprites.inc
$(HGR_SPRITE) -s -l baby_sm_sprite bob_sprites.png 14 58 33 63 >> bob_sprites.inc
####
clean:
rm -f *~ *.o *.lst *.zx02 *.hgr sb_sprites.inc bob_sprites.inc

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@ -0,0 +1,85 @@
;; HARDWARE LOCATIONS
KEYPRESS = $C000
KEYRESET = $C010
;; SOFT SWITCHES
CLR80COL = $C000 ; PAGE1/PAGE2 normal
SET80COL = $C001 ; PAGE1/PAGE1 switches PAGE1 in Aux instead
EIGHTYCOLOFF = $C00C
EIGHTYCOLON = $C00D
SPEAKER = $C030
SET_GR = $C050
SET_TEXT = $C051
FULLGR = $C052
TEXTGR = $C053
PAGE1 = $C054
PAGE2 = $C055
LORES = $C056 ; Enable LORES graphics
HIRES = $C057 ; Enable HIRES graphics
AN3 = $C05E ; Annunciator 3
PADDLE_BUTTON0 = $C061
PADDL0 = $C064
PTRIG = $C070
;=================
; ROM ROUTINES
;=================
; note we can't use these if language card RAM switched in
NORMAL = $F273
HGR = $F3E2
HLINE = $F819 ;; HLINE Y,$2C at A
VLINE = $F828 ;; VLINE A,$2D at Y
CLRSCR = $F832 ;; Clear low-res screen
CLRTOP = $F836 ;; clear only top of low-res screen
SETCOL = $F864 ;; COLOR=A
TEXT = $FB36
TABV = $FB5B ;; VTAB to A
BASCALC = $FBC1 ;;
VTAB = $FC22 ;; VTAB to CV
HOME = $FC58 ;; Clear the text screen
WAIT = $FCA8 ;; delay 1/2(26+27A+5A^2) us
SETINV = $FE80 ;; INVERSE
SETNORM = $FE84 ;; NORMAL
COUT = $FDED ;; output A to screen
COUT1 = $FDF0 ;; output A to screen
COLOR_BLACK = 0
COLOR_RED = 1
COLOR_DARKBLUE = 2
COLOR_PURPLE = 3
COLOR_DARKGREEN = 4
COLOR_GREY = 5
COLOR_MEDIUMBLUE = 6
COLOR_LIGHTBLUE = 7
COLOR_BROWN = 8
COLOR_ORANGE = 9
COLOR_GREY2 = 10
COLOR_PINK = 11
COLOR_LIGHTGREEN = 12
COLOR_YELLOW = 13
COLOR_AQUA = 14
COLOR_WHITE = 15
COLOR_BOTH_BLACK = $00
COLOR_BOTH_RED = $11
COLOR_BOTH_DARKBLUE = $22
COLOR_BOTH_DARKGREEN = $44
COLOR_BOTH_GREY = $55
COLOR_BOTH_MEDIUMBLUE = $66
COLOR_BOTH_LIGHTBLUE = $77
COLOR_BOTH_BROWN = $88
COLOR_BOTH_ORANGE = $99
COLOR_BOTH_PINK = $BB
COLOR_BOTH_LIGHTGREEN = $CC
COLOR_BOTH_YELLOW = $DD
COLOR_BOTH_AQUA = $EE
COLOR_BOTH_WHITE = $FF

View File

@ -0,0 +1,54 @@
; special case
;=========================================================
; hgr copy from $A000/$8000 to current DRAW_PAGE
;=========================================================
; would be faster if we unroll it, but much bigger
; old numbers
; 14+ ((14*256)+20)*32 + 5 = 115347 = 8.6fps
; theoretical unrolled, 30*6 bytes bigger (180 bytes?)
; 2 + ((9*32)+5)*256 + 5 = 75015 = 13.3 fps
hgr_copy:
; copy from in A ($80/$A0)
sta hgr_copy_smc+2 ; 4
clc
adc #$20
sta hgr_copy_end_smc+1
; lda #$A0 ; 2
ldx #0 ; 2
lda DRAW_PAGE
clc
adc #$20
sta hgr_copy_smc+5 ; 4
hgr_copy_column:
hgr_copy_smc:
lda $8000,X ; 4
sta $2000,X ; 5
dex ; 2
bne hgr_copy_column ; 2nt/3t
inc hgr_copy_smc+2 ; 6
inc hgr_copy_smc+5 ; 6
lda hgr_copy_smc+2 ; 4
hgr_copy_end_smc:
cmp #$C0 ; 2
bne hgr_copy_column ; 2/3
rts ; 6

View File

@ -0,0 +1,205 @@
;===========================================
; 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

146
games/sb/fish/hgr_tables.s Normal file
View File

@ -0,0 +1,146 @@
;div7_table = $9C00
;mod7_table = $9D00
;hposn_high = $9E00
;hposn_low = $9F00
;=====================
; make /7 %7 tables
;=====================
; HGR_PAGE should be $20/$40 to select if default for hposn
; is page1 or page2
hgr_make_tables:
ldy #0
lda #0
ldx #0
div7_loop:
sta div7_table,Y
inx
cpx #7
bne div7_not7
clc
adc #1
ldx #0
div7_not7:
iny
bne div7_loop
ldy #0
lda #0
mod7_loop:
sta mod7_table,Y
clc
adc #1
cmp #7
bne mod7_not7
lda #0
mod7_not7:
iny
bne mod7_loop
; Hposn table
lda #0
hposn_loop:
ldy #0
ldx #0
pha
jsr hposn ; (Y,X),(A)
pla
tax
lda GBASL
sta hposn_low,X
lda GBASH
sta hposn_high,X
inx
txa
cmp #192
bne hposn_loop
rts
; left masks
; in memory on screen
; x111 1111 1111111 start at 0
; x111 1110 0111111 start at 1
; x111 1100 0011111 start at 2
; ...
; x100 0000 0000001 start at 6
left_masks:
.byte $FF,$FE,$FC,$F8, $F0,$E0,$C0
; right masks
; in memory on screen
; x000 0001 1000000 end at 0
; x000 0011 1100000 end at 1
; x000 0111 1110000 end at 2
; ...
; x011 1111 1111110 end at 5
; x111 1111 1111111 end at 6
right_masks:
.byte $81,$83,$87, $8F,$9F,$BF,$FF
; from the Apple II firmware
hposn:
; sta HGR_Y ; save Y and X positions
; stx HGR_X
; sty HGR_X+1
pha ; Y pos on stack
and #$C0 ; calc base addr for Y-pos
sta GBASL
lsr
lsr
ora GBASL
sta GBASL
pla
sta GBASH
asl
asl
asl
rol GBASH
asl
rol GBASH
asl
ror GBASL
lda GBASH
and #$1F
ora HGR_PAGE ; default is $40 in this game
sta GBASH
; txa
; cpy #0
; beq xpos_lessthan_256
; ldy #35
; adc #4
;label_1:
; iny
;xpos_lessthan_256:
; sbc #7
; bcs label_1
rts

224
games/sb/fish/zp.inc Normal file
View File

@ -0,0 +1,224 @@
;; Zero Page
;; ZX02 addresses
ZP=$00
offset = ZP+0
ZX0_src = ZP+2
ZX0_dst = ZP+4
bitr = ZP+6
pntr = ZP+7
WHICH_LOAD = $09
;; Zero page monitor routines addresses
WNDLFT = $20
WNDWDTH = $21
WNDTOP = $22
WNDBTM = $23
CH = $24
CV = $25
GBASL = $26
GBASH = $27
BASL = $28
BASH = $29
H2 = $2C
V2 = $2D
MASK = $2E
COLOR = $30
; Electric Duet ZP usage
FREQ1 = $06
FREQ2 = $07
DURATION = $08
INSTRUMENT1 = $09
INSTRUMENT2 = $1D
MADDRL = $1E
MADDRH = $1F
LOC4E = $4E
COUNT256 = $4F
WHICH_PAGE = $50
; dos33 zero page = 26-2f, 35-38, 3e 3f 40-4d
; overlap applesoft 67-6a,6f,70,af,b0,ca-cd,d8
FRAME = $60
FRAMEH = $61
SCROLL = $62
XSAVE = $63
SCROLL_OFFSET = $64
BTC_L = $65
BTC_H = $66
SOUND_STATUS = $67
SOUND_DISABLED = $80
SOUND_IN_LC = $01 ; $01 sound effects in language card
SOUND_MOCKINGBOARD = $02 ; mockingboard detected
MENU_ITEM = $68
OLD_MENU_ITEM = $69
NOT_FIRST_TIME = $6A
STRONGBAD_X = $6B
PLAYER_X = $6C
STRONGBAD_DIR = $6D
SHIELD_POSITION = $6E
SHIELD_DOWN = 0
SHIELD_UP_LEFT = 1
SHIELD_UP_CENTER = 2
SHIELD_UP_RIGHT = 3
SHIELD_COUNT = $6F
BULLET_X = $70
BULLET_X_L = $71
BULLET_Y = $72
HEAD_DAMAGE = $73
BULLET_X_VEL = $74
BULLET_X_VEL_L = $75
BULLET_YDIR = $76
.if 0
REGISTER_DUMP = $70
A_FINE_TONE = $70
A_COARSE_TONE = $71
B_FINE_TONE = $72
B_COARSE_TONE = $73
C_FINE_TONE = $74
C_COARSE_TONE = $75
NOISE = $76
ENABLE = $77
A_VOLUME = $78
B_VOLUME = $79
C_VOLUME = $7A
ENVELOPE_FINE = $7B
ENVELOPE_COARSE = $7C
ENVELOPE_SHAPE = $7D
COPY_OFFSET = $7E
DECODER_STATE = $7F
REGISTER_DUMP2 = $80
A_FINE_TONE2 = $80
A_COARSE_TONE2 = $81
B_FINE_TONE2 = $82
B_COARSE_TONE2 = $83
C_FINE_TONE2 = $84
C_COARSE_TONE2 = $85
NOISE2 = $86
ENABLE2 = $87
A_VOLUME2 = $88
B_VOLUME2 = $89
C_VOLUME2 = $8A
ENVELOPE_FINE2 = $8B
ENVELOPE_COARS2 = $8C
ENVELOPE_SHAPE2 = $8D
LYRICSL = $8E
LYRICSH = $8F
.endif
FRAME_COUNT = $90
MB_VALUE = $91
MB_ADDRL = $91
MB_ADDRH = $92
DONE_PLAYING = $93
MB_CHUNK_OFFSET = $94
MB_FRAME = $94
MB_PATTERN = $95
CHUNKSIZE = $95
LZ4_DONE = $96
DECODE_ERROR = $97
COPY_TIME = $98
DECOMPRESS_TIME = $99
TIME_TAKEN = $9A
LYRICS_ACTIVE = $9B
;FORTYCOL = $9C
CURSOR = $9D
CURRENT_DISK = $DC
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
D1_SCORE = $E0
D1_SCORE_H = $E1
D2_SCORE = $E2
D2_SCORE_H = $E3
D1_STATE = $E4
DUCK_MISSING = $00
DUCK_LEFT = $00
DUCK_RIGHT = $80
DUCK_NORMAL = $01
DUCK_MOVE = $02
DUCK_FEEDING = $03
D2_STATE = $E5
D1_XPOS = $E6
D2_XPOS = $E7
D1_YPOS = $E8
D2_YPOS = $E9
D1_XSPEED = $EA
D2_XSPEED = $EB
D1_YSPEED = $EC
D2_YSPEED = $ED
OLD_X = $EC
OLDER_X = $ED
DISP_PAGE = $EE
DRAW_PAGE = $EF
XPOS = $F0
YPOS = $F1
XMAX = $F2
SPRITE_X = $F3
SPRITE_Y = $F4
HGR_PAGE = $F5
CURRENT_ROW = $F6
TEMP = $F8
TEMPY = $F9
MASKL = $FA
MASKH = $FB
INL = $FC
INH = $FD
OUTL = $FE
OUTH = $FF
; read any file slot 6 version
; based on FASTLD6 and RTS copyright (c) Peter Ferrie 2011-2013,2018
; modified to assembled with ca64 -- vmw
; added code to patch it to run from current disk slot -- vmw
adrlo = $26 ; constant from boot prom
adrhi = $27 ; constant from boot prom
tmpsec = $3c ; constant from boot prom
reqsec = $3d ; constant from boot prom
sizelo = $44
sizehi = $45
secsize = $46
ldsizel = $f0
ldsizeh = $f1
namlo = $fb
namhi = $fc
step = $fd ; state for stepper motor
tmptrk = $fe ; temporary copy of current track
phase = $ff ; current phase for /seek