gr: split off starfield demo

This commit is contained in:
Vince Weaver 2021-01-06 10:45:48 -05:00
parent f9d6554425
commit b6e50f80b9
19 changed files with 1350 additions and 29 deletions

View File

@ -11,16 +11,13 @@ $(DOS33):
cd ../../../utils/dos33fs-utils && make
mode7.dsk: $(DOS33) MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST RASTERBARS SKY_DEMO \
STARFIELD_DEMO STARFIELD_1K TEXT_DEMO
PLOT_TEST RASTERBARS SKY_DEMO TEXT_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_ISLAND
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_CHECKERBOARD
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 MODE7_RAINBOW
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 PLOT_TEST
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 RASTERBARS
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 SKY_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_DEMO
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 STARFIELD_1K
$(DOS33) -y mode7.dsk BSAVE -a 0x1000 TEXT_DEMO
@ -93,17 +90,6 @@ sky_demo.o: sky_demo.s \
gr_setpage.s
ca65 -o sky_demo.o sky_demo.s -l sky_demo.lst
STARFIELD_DEMO: starfield_demo.o
ld65 -o STARFIELD_DEMO starfield_demo.o -C ./apple2_1000.inc
starfield_demo.o: starfield_demo.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s \
gr_fast_clear.s
ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst
RASTERBARS: rasterbars.o
ld65 -o RASTERBARS rasterbars.o -C ./apple2_1000.inc
@ -114,18 +100,6 @@ rasterbars.o: rasterbars.s \
gr_fast_clear.s
ca65 -o rasterbars.o rasterbars.s -l rasterbars.lst
STARFIELD_1K: starfield_1k.o
ld65 -o STARFIELD_1K starfield_1k.o -C ./apple2_1000.inc
starfield_1k.o: starfield_1k.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s \
gr_fast_clear.s
ca65 -o starfield_1k.o starfield_1k.s -l starfield_1k.lst
TEXT_DEMO: text_demo.o
ld65 -o TEXT_DEMO text_demo.o -C ./apple2_1000.inc
@ -151,6 +125,5 @@ background.o: background.c
clean:
rm -f *~ *.o scroller background \
MODE7 MODE7_ISLAND MODE7_CHECKERBOARD MODE7_RAINBOW \
PLOT_TEST RASTERBARS STARFIELD_DEMO STARFIELD_1K \
SKY_DEMO TEXT_DEMO *.lst
PLOT_TEST RASTERBARS SKY_DEMO TEXT_DEMO *.lst

BIN
graphics/gr/starfield/HELLO Normal file

Binary file not shown.

View File

@ -0,0 +1,53 @@
include ../../../Makefile.inc
DOS33 = ../../../utils/dos33fs-utils/dos33
PNG2GR = ../../../utils/gr-utils/png2gr
PNG2RLE = ../../../utils/gr-utils/png2rle
TOKENIZE = ../../../utils/asoft_basic-utils/tokenize_asoft
LINKERSCRIPTS = ../../../linker_scripts
all: starfield.dsk
$(DOS33):
cd ../../../utils/dos33fs-utils && make
starfield.dsk: $(DOS33) HELLO STARFIELD_DEMO STARFIELD_1K
cp empty.dsk starfield.dsk
$(DOS33) -y starfield.dsk SAVE A HELLO
$(DOS33) -y starfield.dsk BSAVE -a 0x1000 STARFIELD_DEMO
$(DOS33) -y starfield.dsk BSAVE -a 0x1000 STARFIELD_1K
###
HELLO: hello.bas
$(TOKENIZE) < hello.bas > HELLO
###
STARFIELD_DEMO: starfield_demo.o
ld65 -o STARFIELD_DEMO starfield_demo.o -C $(LINKERSCRIPTS)/apple2_1000.inc
starfield_demo.o: starfield_demo.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s \
gr_fast_clear.s
ca65 -o starfield_demo.o starfield_demo.s -l starfield_demo.lst
###
STARFIELD_1K: starfield_1k.o
ld65 -o STARFIELD_1K starfield_1k.o -C $(LINKERSCRIPTS)/apple2_1000.inc
starfield_1k.o: starfield_1k.s \
gr_scroll.s \
pageflip.s \
gr_setpage.s \
gr_fast_clear.s
ca65 -o starfield_1k.o starfield_1k.s -l starfield_1k.lst
###
clean:
rm -f *~ *.o STARFIELD_DEMO STARFIELD_1K *.lst

Binary file not shown.

View File

@ -0,0 +1,193 @@
clear_screens:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_top
jsr clear_bottom
rts
clear_bottoms:
;===================================
; Clear bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_bottom
;===================================
; Clear bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_bottom
rts
;=========================================================
; clear_top
;=========================================================
; clear DRAW_PAGE
; original = 14,558 cycles(?) 15ms, 70Hz
; OPTIMIZED MAX (page0,48rows): 45*120+4+6 = 5410 = 5.4ms 185Hz
; (pageX,40rows): 50*120+4+6 = 6010 = 6.0ms 166Hz
; 50*120+4+6+37 = 6055 = 6.0ms 166Hz
clear_top:
lda #0 ; 2
clear_top_a:
sta COLOR ; 3
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __ctf+2 ; 3
sta __ctf+5 ; 3
adc #1 ; 2
sta __ctf+8 ; 3
sta __ctf+11 ; 3
adc #1 ; 2
sta __ctf2+2 ; 3
sta __ctf2+5 ; 3
adc #1 ; 2
sta __ctf2+8 ; 3
sta __ctf2+11 ; 3
ldy #120 ; 2
lda COLOR ; 3
clear_top_fast_loop:
__ctf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
cpy #80 ; 2
bpl no_draw_bottom ; 2nt/3
__ctf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
no_draw_bottom:
dey ; 2
bpl clear_top_fast_loop ; 2nt/3
rts ; 6
;=========================================================
; clear_bottom
;=========================================================
; clear bottom of draw page
clear_bottom:
clc ; 2
lda DRAW_PAGE ; 3
adc #6 ; 2
sta __cbf2+2 ; 3
sta __cbf2+5 ; 3
adc #1 ; 2
sta __cbf2+8 ; 3
sta __cbf2+11 ; 3
ldy #120 ; 2
lda #$a0 ; Normal Space ; 2
clear_bottom_fast_loop:
__cbf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
cpy #80 ; 2
bpl clear_bottom_fast_loop ; 2nt/3
rts ; 6
clear_screens_notext:
;===================================
; Clear top/bottom of page 0
;===================================
lda #$0
sta DRAW_PAGE
jsr clear_all
;===================================
; Clear top/bottom of page 1
;===================================
lda #$4
sta DRAW_PAGE
jsr clear_all
rts
;=========================================================
; clear_all
;=========================================================
; clear 48 rows
; clear color: clear_all_color+1
clear_all:
clc ; 2
lda DRAW_PAGE ; 3
adc #4 ; 2
sta __caf+2 ; 3
sta __caf+5 ; 3
adc #1 ; 2
sta __caf+8 ; 3
sta __caf+11 ; 3
adc #1 ; 2
sta __caf2+2 ; 3
sta __caf2+5 ; 3
adc #1 ; 2
sta __caf2+8 ; 3
sta __caf2+11 ; 3
ldy #120 ; 2
clear_all_color:
lda #0 ; 2
clear_all_fast_loop:
__caf:
sta $400,Y ; 5
sta $480,Y ; 5
sta $500,Y ; 5
sta $580,Y ; 5
__caf2:
sta $600,Y ; 5
sta $680,Y ; 5
sta $700,Y ; 5
sta $780,Y ; 5
dey ; 2
bpl clear_all_fast_loop ; 2nt/3
rts ; 6

View File

@ -0,0 +1,5 @@
; move these to zero page for slight speed increase?
gr_offsets:
.word $400,$480,$500,$580,$600,$680,$700,$780
.word $428,$4a8,$528,$5a8,$628,$6a8,$728,$7a8
.word $450,$4d0,$550,$5d0,$650,$6d0,$750,$7d0

View File

@ -0,0 +1,48 @@
;================================
; plot routine
;================================
; Xcoord in XPOS
; Ycoord in YPOS
; color in COLOR
plot:
lda YPOS ; 2
lsr ; shift bottom bit into carry ; 2
bcc plot_even ; 2nt/3
plot_odd:
ldx #$f0 ; 2
bcs plot_c_done ; 2nt/3
plot_even:
ldx #$0f ; 2
plot_c_done:
stx MASK ; 3
asl ; shift back (now even) ; 2
tay
lda gr_offsets,Y ; lookup low-res memory address ; 4
clc ; 2
adc XPOS ; 3
sta GBASL ; 3
iny ; 2
lda gr_offsets,Y ; 4
adc DRAW_PAGE ; add in draw page offset ; 3
sta GBASH ; 3
ldy #0 ; 2
plot_write:
lda MASK ; 3
eor #$ff ; 2
and (GBASL),Y ; 5
sta COLOR_MASK ; 3
lda COLOR ; 3
and MASK ; 3
ora COLOR_MASK ; 3
sta (GBASL),Y ; 5
rts ; 6

View File

@ -0,0 +1,101 @@
;=============================================
; put_sprite
;=============================================
; Sprite to display in INH,INL
; Location is XPOS,YPOS
; Note, only works if YPOS is multiple of two?
put_sprite:
ldy #0 ; byte 0 is xsize ; 2
lda (INL),Y ; 5
sta CH ; xsize is in CH ; 3
iny ; 2
lda (INL),Y ; byte 1 is ysize ; 5
sta CV ; ysize is in CV ; 3
iny ; 2
lda YPOS ; make a copy of ypos ; 3
sta TEMPY ; as we modify it ; 3
;===========
; 28
put_sprite_loop:
sty TEMP ; save sprite pointer ; 3
ldy TEMPY ; 3
lda gr_offsets,Y ; lookup low-res memory address ; 5
clc ; 2
adc XPOS ; add in xpos ; 3
sta OUTL ; store out low byte of addy ; 3
lda gr_offsets+1,Y ; look up high byte ; 5
adc DRAW_PAGE ; ; 3
sta OUTH ; and store it out ; 3
ldy TEMP ; restore sprite pointer ; 3
; OUTH:OUTL now points at right place
ldx CH ; load xsize into x ; 3
;===========
; 36
put_sprite_pixel:
lda (INL),Y ; get sprite colors ; 5
iny ; increment sprite pointer ; 2
sty TEMP ; save sprite pointer ; 3
ldy #$0 ; 2
; check if completely transparent
; if so, skip
cmp #$0 ; if all zero, transparent ; 2
beq put_sprite_done_draw ; don't draw it ; 2nt/3
; FIXME: use BIT? ;==============
; 17
sta COLOR ; save color for later ; 3
; check if top pixel transparent
and #$f0 ; check if top nibble zero ; 2
bne put_sprite_bottom ; if not skip ahead ; 2nt/3
lda #$f0 ; setup mask ; 2
sta MASK ; 3
bmi put_sprite_mask ; 2nt/3
put_sprite_bottom:
lda COLOR ; re-load color ; 3
and #$0f ; check if bottom nibble zero ; 2
bne put_sprite_all ; if not, skip ahead ; 2nt/3
lda #$0f ; 2
sta MASK ; setup mask ; 3
put_sprite_mask:
lda (OUTL),Y ; get color at output ; 5
and MASK ; mask off unneeded part ; 3
ora COLOR ; or the color in ; 3
sta (OUTL),Y ; store it back ; 5
jmp put_sprite_done_draw ; we are done ; 3
put_sprite_all:
lda COLOR ; load color ; 3
sta (OUTL),Y ; and write it out ; 5
put_sprite_done_draw:
ldy TEMP ; restore sprite pointer ; 3
inc OUTL ; increment output pointer ; 5
dex ; decrement x counter ; 2
bne put_sprite_pixel ; if not done, keep looping ; 2nt/3
inc TEMPY ; each line has two y vars ; 5
inc TEMPY ; 5
dec CV ; decemenet total y count ; 5
bne put_sprite_loop ; loop if not done ; 2nt/3
rts ; return ; 6

View File

@ -0,0 +1,195 @@
.ifndef scroll_row1
scroll_row1 EQU $8A00
scroll_row2 EQU $8B00
scroll_row3 EQU $8C00
scroll_row4 EQU $8D00
.endif
SCROLL_LENGTH EQU $61
OFFSET EQU $62
;========================
; scroll some text
;========================
; RLE compressed data in INL/INH
; CV is Y position to display at
gr_scroll:
lda #0
sta OFFSET
;=======================
; decompress scroll text
;=======================
jsr decompress_scroll
scroll_loop:
ldx #0
ldy CV
lsr
lda gr_offsets,Y ; get position
sta sm1+1
lda gr_offsets+2,Y ; get position
sta sm2+1
lda gr_offsets+4,Y ; get position
sta sm3+1
lda gr_offsets+6,Y ; get position
sta sm4+1
iny
clc
lda gr_offsets,Y ; get position
adc DRAW_PAGE
sta sm1+2
lda gr_offsets+2,Y ; get position
adc DRAW_PAGE
sta sm2+2
lda gr_offsets+4,Y ; get position
adc DRAW_PAGE
sta sm3+2
lda gr_offsets+6,Y ; get position
adc DRAW_PAGE
sta sm4+2
ldy OFFSET
draw_loop:
lda scroll_row1,Y
sm1:
sta $400,X
lda scroll_row2,Y
sm2:
sta $480,X
lda scroll_row3,Y
sm3:
sta $500,X
lda scroll_row4,Y
sm4:
sta $580,X
iny
inx
cpx #40
bne draw_loop
;==================
; flip pages
;==================
jsr page_flip ; 6
;==================
; delay
;==================
lda #125
jsr WAIT
;==================
; loop forever
;==================
clc
lda OFFSET
adc #40
cmp SCROLL_LENGTH
beq done_scrolling
inc OFFSET
jmp scroll_loop ; 3
done_scrolling:
rts
;=======================
; decompress scroll
;=======================
decompress_scroll:
ldy #0
jsr scroll_load_and_increment
sta SCROLL_LENGTH
lda #<scroll_row1
sta OUTL
lda #>scroll_row1
sta OUTH
decompress_scroll_loop:
jsr scroll_load_and_increment ; load compressed value
cmp #$A1 ; EOF marker
beq done_decompress_scroll ; if EOF, exit
pha ; save
and #$f0 ; mask
cmp #$a0 ; see if special AX
beq decompress_scroll_special
pla ; note, PLA sets flags!
ldx #$1 ; only want to print 1
bne decompress_scroll_run
decompress_scroll_special:
pla
and #$0f ; check if was A0
bne decompress_scroll_color ; if A0 need to read run, color
decompress_scroll_large:
jsr scroll_load_and_increment ; get run length
decompress_scroll_color:
tax ; put runlen into X
jsr scroll_load_and_increment ; get color
decompress_scroll_run:
sta (OUTL),Y
pha
clc ; increment 16-bit pointer
lda OUTL
adc #$1
sta OUTL
lda OUTH
adc #$0
sta OUTH
pla
dex ; repeat for X times
bne decompress_scroll_run
beq decompress_scroll_loop ; get next run
done_decompress_scroll:
rts
scroll_load_and_increment:
lda (INL),Y ; load and increment 16-bit pointer
pha
clc
lda INL
adc #$1
sta INL
lda INH
adc #$0
sta INH
pla
rts

View File

@ -0,0 +1,20 @@
;==========================================================
; set_text_page0
;==========================================================
;
set_text_page0:
bit PAGE0 ; set page0
bit TEXT ; set text mode
rts
;==========================================================
; set_gr_page0
;==========================================================
;
set_gr_page0:
bit PAGE0 ; set page 0
bit LORES ; Lo-res graphics
bit TEXTGR ; mixed gr/text mode
bit SET_GR ; set graphics
rts

View File

@ -0,0 +1,2 @@
5 HOME
10 PRINT CHR$(4);"CATALOG"

View File

@ -0,0 +1,111 @@
;==========================================================
; Wait until keypressed
;==========================================================
;
wait_until_keypressed:
lda KEYPRESS ; check if keypressed
bpl wait_until_keypressed ; if not, loop
jmp figure_out_key
;==========================================================
; Get Key
;==========================================================
;
get_key:
check_paddle_button:
; check for paddle button
bit PADDLE_BUTTON0 ; 4
bpl no_button ; 2nt/3
lda #' '+128 ; 2
jmp save_key ; 3
no_button:
lda KEYPRESS ; 3
bpl no_key ; 2nt/3
figure_out_key:
cmp #' '+128 ; the mask destroys space ; 2
beq save_key ; so handle it specially ; 2nt/3
and #$5f ; mask, to make upper-case ; 2
check_right_arrow:
cmp #$15 ; 2
bne check_left_arrow ; 2nt/3
lda #'D' ; 2
check_left_arrow:
cmp #$08 ; 2
bne check_up_arrow ; 2nt/3
lda #'A' ; 2
check_up_arrow:
cmp #$0B ; 2
bne check_down_arrow ; 2nt/3
lda #'W' ; 2
check_down_arrow:
cmp #$0A ; 2
bne check_escape ; 2nt/3
lda #'S' ; 2
check_escape:
cmp #$1B ; 2
bne save_key ; 2nt/3
lda #'Q' ; 2
jmp save_key ; 3
no_key:
bit PADDLE_STATUS ; 3
bpl no_key_store ; 2nt/3
; check for paddle action
; code from http://web.pdx.edu/~heiss/technotes/aiie/tn.aiie.06.html
inc PADDLE_STATUS ; 5
lda PADDLE_STATUS ; 3
and #$03 ; 2
beq check_paddles ; 2nt/3
jmp no_key_store ; 3
check_paddles:
lda PADDLE_STATUS ; 3
and #$80 ; 2
sta PADDLE_STATUS ; 3
ldx #$0 ; 2
LDA PTRIG ;TRIGGER PADDLES ; 4
LDY #0 ;INIT COUNTER ; 2
NOP ;COMPENSATE FOR 1ST COUNT ; 2
NOP ; 2
PREAD2: LDA PADDL0,X ;COUNT EVERY 11 uSEC. ; 4
BPL RTS2D ;BRANCH WHEN TIMED OUT ; 2nt/3
INY ;INCREMENT COUNTER ; 2
BNE PREAD2 ;CONTINUE COUNTING ; 2nt/3
DEY ;COUNTER OVERFLOWED ; 2
RTS2D: ;RETURN W/VALUE 0-255
cpy #96 ; 2
bmi paddle_left ; 2nt/3
cpy #160 ; 2
bmi no_key_store ; 2nt/3
lda #'D' ; 2
jmp save_key ; 3
paddle_left:
lda #'A' ; 2
jmp save_key ; 3
no_key_store:
lda #0 ; no key, so save a zero ; 2
save_key:
sta LASTKEY ; save the key to our buffer ; 2
bit KEYRESET ; clear the keyboard buffer ; 4
rts ; 6
;============
; 33=nokey
; 48=worstkey

View File

@ -0,0 +1,351 @@
; Fast mutiply
; Note for our purposes we only care about 8.8 x 8.8 fixed point
; with 8.8 result, which means we only care about the middle two bytes
; of the 32 bit result. So we disable generation of the high and low byte
; to save some cycles.
;
; The old routine took around 700 cycles for a 16bitx16bit=32bit mutiply
; This routine, at an expense of 2kB of looku tables, takes around 250
; If you reuse a term the next time this drops closer to 200
; This routine was described by Stephen Judd and found
; in The Fridge and in the C=Hacking magazine
; http://codebase64.org/doku.php?id=base:seriously_fast_multiplication
; The key thing to note is that
; (a+b)^2 (a-b)^2
; a*b = ------- - --------
; 4 4
; So if you have tables of the squares of 0..511 you can lookup and subtract
; instead of multiplying.
; Table generation: I:0..511
; square1_lo = <((I*I)/4)
; square1_hi = >((I*I)/4)
; square2_lo = <(((I-255)*(I-255))/4)
; square2_hi = >(((I-255)*(I-255))/4)
; Note: DOS3.3 starts at $9600
.ifndef square1_lo
square1_lo EQU $8E00
square1_hi EQU $9000
square2_lo EQU $9200
square2_hi EQU $9400
.endif
; for(i=0;i<512;i++) {
; square1_lo[i]=((i*i)/4)&0xff;
; square1_hi[i]=(((i*i)/4)>>8)&0xff;
; square2_lo[i]=( ((i-255)*(i-255))/4)&0xff;
; square2_hi[i]=(( ((i-255)*(i-255))/4)>>8)&0xff;
; }
init_multiply_tables:
; Build the add tables
ldx #$00
txa
.byte $c9 ; CMP #immediate - skip TYA and clear carry flag
lb1: tya
adc #$00 ; 0
ml1: sta square1_hi,x ; square1_hi[0]=0
tay ; y=0
cmp #$40 ; subtract 64 and update flags (c=0)
txa ; a=0
ror ; rotate
ml9: adc #$00 ; add 0
sta ml9+1 ; update add value
inx ; x=1
ml0: sta square1_lo,x ; square1_lo[0]=1
bne lb1 ; if not zero, loop
inc ml0+2 ; increment values
inc ml1+2 ; increment values
clc ; c=0
iny ; y=1
bne lb1 ; loop
; Build the subtract tables based on the existing one
ldx #$00
ldy #$ff
second_table:
lda square1_hi+1,x
sta square2_hi+$100,x
lda square1_hi,x
sta square2_hi,y
lda square1_lo+1,x
sta square2_lo+$100,x
lda square1_lo,x
sta square2_lo,y
dey
inx
bne second_table
rts
; Fast 16x16 bit unsigned multiplication, 32-bit result
; Input: NUM1H:NUM1L * NUM2H:NUM2L
; Result: RESULT3:RESULT2:RESULT1:RESULT0
;
; Does self-modifying code to hard-code NUM1H:NUM1L into the code
; carry=0: re-use previous NUM1H:NUM1L
; carry=1: reload NUM1H:NUM1L (58 cycles slower)
;
; clobbered: RESULT, X, A, C
; Allocation setup: T1,T2 and RESULT preferably on Zero-page.
;
; NUM1H (x_i), NUM1L (x_f)
; NUM2H (y_i), NUM2L (y_f)
; NUM1L * NUM2L = AAaa
; NUM1L * NUM2H = BBbb
; NUM1H * NUM2L = CCcc
; NUM1H * NUM2H = DDdd
;
; AAaa
; BBbb
; CCcc
; + DDdd
; ----------
; RESULT
;fixed_16x16_mul_unsigned:
multiply:
bcc num1_same_as_last_time ; 2nt/3
;============================
; Set up self-modifying code
; this changes the code to be hard-coded to multiply by NUM1H:NUM1L
;============================
lda NUM1L ; load the low byte ; 3
sta sm1a+1 ; 3
sta sm3a+1 ; 3
sta sm5a+1 ; 3
sta sm7a+1 ; 3
eor #$ff ; invert the bits for subtracting ; 2
sta sm2a+1 ; 3
sta sm4a+1 ; 3
sta sm6a+1 ; 3
sta sm8a+1 ; 3
lda NUM1H ; load the high byte ; 3
sta sm1b+1 ; 3
sta sm3b+1 ; 3
sta sm5b+1 ; 3
; sta sm7b+1 ;
eor #$ff ; invert the bits for subtractin ; 2
sta sm2b+1 ; 3
sta sm4b+1 ; 3
sta sm6b+1 ; 3
; sta sm8b+1 ;
;===========
; 52
num1_same_as_last_time:
;==========================
; Perform NUM1L * NUM2L = AAaa
;==========================
ldx NUM2L ; (low le) ; 3
sec ; 2
sm1a:
lda square1_lo,x ; 4
sm2a:
sbc square2_lo,x ; 4
; a is _aa
; sta RESULT+0 ;
sm3a:
lda square1_hi,x ; 4
sm4a:
sbc square2_hi,x ; 4
; a is _AA
sta _AA+1 ; 3
;===========
; 24
; Perform NUM1H * NUM2L = CCcc
sec ; 2
sm1b:
lda square1_lo,x ; 4
sm2b:
sbc square2_lo,x ; 4
; a is _cc
sta _cc+1 ; 3
sm3b:
lda square1_hi,x ; 4
sm4b:
sbc square2_hi,x ; 4
; a is _CC
sta _CC+1 ; 3
;===========
; 24
;==========================
; Perform NUM1L * NUM2H = BBbb
;==========================
ldx NUM2H ; 3
sec ; 2
sm5a:
lda square1_lo,x ; 4
sm6a:
sbc square2_lo,x ; 4
; a is _bb
sta _bb+1 ; 3
sm7a:
lda square1_hi,x ; 4
sm8a:
sbc square2_hi,x ; 4
; a is _BB
sta _BB+1 ; 3
;===========
; 27
;==========================
; Perform NUM1H * NUM2H = DDdd
;==========================
sec ; 2
sm5b:
lda square1_lo,x ; 4
sm6b:
sbc square2_lo,x ; 4
; a is _dd
sta _dd+1 ; 3
;sm7b:
; lda square1_hi,x ;
;sm8b:
; sbc square2_hi,x ;
; a = _DD
; sta RESULT+3 ;
;===========
; 13
;===========================================
; Add the separate multiplications together
;===========================================
clc ; 2
_AA:
lda #0 ; loading _AA ; 2
_bb:
adc #0 ; adding in _bb ; 2
sta RESULT+1 ; 3
;==========
; 9
; product[2]=_BB+_CC+c
_BB:
lda #0 ; loading _BB ; 2
_CC:
adc #0 ; adding in _CC ; 2
sta RESULT+2 ; 3
;===========
; 7
; product[3]=_DD+c
; bcc dd_no_carry1 ;
; inc RESULT+3 ;
clc ; 2
;=============
; 2
dd_no_carry1:
; product[1]=_AA+_bb+_cc
_cc:
lda #0 ; load _cc ; 2
adc RESULT+1 ; 3
sta RESULT+1 ; 3
; product[2]=_BB+_CC+_dd+c
_dd:
lda #0 ; load _dd ; 2
adc RESULT+2 ; 3
sta RESULT+2 ; 3
;===========
; 16
; product[3]=_DD+c
; bcc dd_no_carry2 ;
; inc RESULT+3 ;
;=============
; 0
dd_no_carry2:
; *z_i=product[1];
; *z_f=product[0];
; rts ; 6
;=================
; Signed multiply
;=================
;multiply:
; jsr fixed_16x16_mul_unsigned ; 6
lda NUM1H ; x_i ; 3
;===========
; 12
bpl x_positive ;^3/2nt
sec ; 2
lda RESULT+2 ; 3
sbc NUM2L ; 3
sta RESULT+2 ; 3
; lda RESULT+3 ;
; sbc NUM2H ;
; sta RESULT+3 ;
;============
; 10
x_positive:
lda NUM2H ; y_i ; 3
;============
; ; 6
bpl y_positive ;^3/2nt
sec ; 2
lda RESULT+2 ; 3
sbc NUM1L ; 3
sta RESULT+2 ; 3
; lda RESULT+3 ;
; sbc NUM1H ;
; sta RESULT+3 ;
;===========
; 10
y_positive:
ldx RESULT+2 ; *z_i=product[2]; ; 3
lda RESULT+1 ; *z_f=product[1]; ; 3
rts ; 6
;==========
; 12

View File

@ -0,0 +1,24 @@
;==========
; page_flip
;==========
page_flip:
lda DISP_PAGE ; 3
beq page_flip_show_1 ; 2nt/3
page_flip_show_0:
bit PAGE0 ; 4
lda #4 ; 2
sta DRAW_PAGE ; DRAW_PAGE=1 ; 3
lda #0 ; 2
sta DISP_PAGE ; DISP_PAGE=0 ; 3
rts ; 6
page_flip_show_1:
bit PAGE1 ; 4
sta DRAW_PAGE ; DRAW_PAGE=0 ; 3
lda #1 ; 2
sta DISP_PAGE ; DISP_PAGE=1 ; 3
rts ; 6
;====================
; DISP_PAGE=0 26
; DISP_PAGE=1 24

View File

@ -0,0 +1,59 @@
;================
; Ship Sprites
;================
splash_forward:
.byte $7,$2
.byte $00,$ee,$00,$00,$00,$ee,$00
.byte $ee,$00,$00,$00,$00,$00,$ee
splash_right:
.byte $7,$2
.byte $00,$00,$00,$00,$00,$ee,$00
.byte $00,$00,$00,$00,$00,$00,$ee
splash_left:
.byte $7,$2
.byte $00,$ee,$00,$00,$00,$00,$00
.byte $ee,$00,$00,$00,$00,$00,$00
shadow_forward:
.byte $3,$2
.byte $00,$aa,$00
.byte $a0,$aa,$a0
shadow_right:
.byte $3,$2
.byte $a0,$00,$aa
.byte $00,$0a,$a0
shadow_left:
.byte $3,$2
.byte $aa,$00,$a0
.byte $a0,$0a,$00
ship_forward:
.byte $9,$5
.byte $00,$00,$00,$00,$ff,$00,$00,$00,$00
.byte $00,$00,$00,$66,$ff,$66,$00,$00,$00
.byte $00,$00,$70,$2f,$12,$2f,$70,$00,$00
.byte $f0,$f7,$f7,$f2,$d9,$f2,$f7,$f7,$f0
.byte $00,$00,$00,$00,$0d,$00,$00,$00,$00
ship_right:
.byte $9,$5
.byte $00,$00,$00,$00,$00,$60,$60,$f0,$00
.byte $00,$f0,$70,$70,$f6,$f6,$6f,$66,$00
.byte $00,$07,$ff,$2f,$12,$27,$f6,$00,$00
.byte $00,$00,$00,$dd,$d9,$f2,$77,$00,$00
.byte $00,$00,$00,$00,$00,$0f,$ff,$70,$00
ship_left:
.byte $9,$5
.byte $00,$f0,$60,$60,$00,$00,$00,$00,$00
.byte $00,$66,$6f,$f6,$f6,$70,$70,$f0,$00
.byte $00,$00,$f6,$27,$12,$2f,$ff,$07,$00
.byte $00,$00,$77,$f2,$d9,$dd,$00,$00,$00
.byte $00,$70,$ff,$0f,$00,$00,$00,$00,$00

Binary file not shown.

View File

@ -0,0 +1,186 @@
.define EQU =
;; Zero page monitor routines addresses
WNDLFT EQU $20
WNDWDTH EQU $21
WNDTOP EQU $22
WNDBTM EQU $23
CH EQU $24
CV EQU $25
GBASL EQU $26
GBASH EQU $27
BASL EQU $28
BASH EQU $29
H2 EQU $2C
V2 EQU $2D
MASK EQU $2E
COLOR EQU $30
INVFLG EQU $32
; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related
COLOR1 EQU $E0
COLOR2 EQU $E1
MATCH EQU $E2
XX EQU $E3
YY EQU $E4
YADD EQU $E5
LOOP EQU $E6
MEMPTRL EQU $E7
MEMPTRH EQU $E8
NAMEL EQU $E9
NAMEH EQU $EA
NAMEX EQU $EB
CHAR EQU $EC
DISP_PAGE EQU $ED
DRAW_PAGE EQU $EE
FIRST EQU $F0
LASTKEY EQU $F1
PADDLE_STATUS EQU $F2
XPOS EQU $F3
YPOS EQU $F4
TEMP EQU $FA
RUN EQU $FA
TEMP2 EQU $FB
TEMPY EQU $FB
INL EQU $FC
INH EQU $FD
OUTL EQU $FE
OUTH EQU $FF
;; Flying Routine Only
TURNING EQU $60
;SCREEN_X EQU $61 ; not used?
SCREEN_Y EQU $62
ANGLE EQU $63
HORIZ_SCALE_I EQU $64
HORIZ_SCALE_F EQU $65
FACTOR_I EQU $66
FACTOR_F EQU $67
DX_I EQU $68
DX_F EQU $69
SPACEX_I EQU $6A
SPACEX_F EQU $6B
CX_I EQU $6C
CX_F EQU $6D
DY_I EQU $6E
DY_F EQU $6F
SPACEY_I EQU $70
SPACEY_F EQU $71
CY_I EQU $72
CY_F EQU $73
TEMP_I EQU $74
TEMP_F EQU $75
DISTANCE_I EQU $76
DISTANCE_F EQU $77
SPACEZ_I EQU $78
SPACEZ_F EQU $79
DRAW_SPLASH EQU $7A
SPEED EQU $7B
SPLASH_COUNT EQU $7C
OVER_LAND EQU $7D
NUM1L EQU $7E
NUM1H EQU $7F
NUM2L EQU $80
NUM2H EQU $81
RESULT EQU $82 ; 83,84,85
NEGATE EQU $86 ; UNUSED?
LAST_SPACEX_I EQU $87
LAST_SPACEY_I EQU $88
LAST_MAP_COLOR EQU $89
DRAW_SKY EQU $8A
COLOR_MASK EQU $8B
RANDOM_POINTER EQU $8C
STATE EQU $8D
SHIPY EQU $E4
KEYPRESS EQU $C000
KEYRESET EQU $C010
;; SOFT SWITCHES
CLR80COL EQU $C000 ; PAGE0/PAGE1 normal
SET80COL EQU $C001 ; PAGE0/PAGE1 switches PAGE0 in Aux instead
EIGHTYCOL EQU $C00D
SPEAKER EQU $C030
SET_GR EQU $C050
SET_TEXT EQU $C051
FULLGR EQU $C052
TEXTGR EQU $C053
PAGE0 EQU $C054
PAGE1 EQU $C055
LORES EQU $C056 ; Enable LORES graphics
HIRES EQU $C057 ; Enable HIRES graphics
AN3 EQU $C05E ; Annunciator 3
PADDLE_BUTTON0 EQU $C061
PADDL0 EQU $C064
PTRIG EQU $C070
;; BASIC ROUTINES
NORMAL EQU $F273
;; MONITOR ROUTINES
HLINE EQU $F819 ;; HLINE Y,$2C at A
VLINE EQU $F828 ;; VLINE A,$2D at Y
CLRSCR EQU $F832 ;; Clear low-res screen
CLRTOP EQU $F836 ;; clear only top of low-res screen
SETCOL EQU $F864 ;; COLOR=A
TEXT EQU $FB36
TABV EQU $FB5B ;; VTAB to A
BASCALC EQU $FBC1 ;;
VTAB EQU $FC22 ;; VTAB to CV
HOME EQU $FC58 ;; Clear the text screen
WAIT EQU $FCA8 ;; delay 1/2(26+27A+5A^2) us
SETINV EQU $FE80 ;; INVERSE
SETNORM EQU $FE84 ;; NORMAL
COUT EQU $FDED ;; output A to screen
COUT1 EQU $FDF0 ;; output A to screen
COLOR_BLACK EQU 0
COLOR_RED EQU 1
COLOR_DARKBLUE EQU 2
COLOR_PURPLE EQU 3
COLOR_DARKGREEN EQU 4
COLOR_GREY EQU 5
COLOR_MEDIUMBLUE EQU 6
COLOR_LIGHTBLUE EQU 7
COLOR_BROWN EQU 8
COLOR_ORANGE EQU 9
COLOR_GREY2 EQU 10
COLOR_PINK EQU 11
COLOR_LIGHTGREEN EQU 12
COLOR_YELLOW EQU 13
COLOR_AQUA EQU 14
COLOR_WHITE EQU 15
COLOR_BOTH_RED EQU $11
COLOR_BOTH_DARKBLUE EQU $22
COLOR_BOTH_DARKGREEN EQU $44
COLOR_BOTH_GREY EQU $55
COLOR_BOTH_MEDIUMBLUE EQU $66
COLOR_BOTH_LIGHTBLUE EQU $77
COLOR_BOTH_BROWN EQU $88
COLOR_BOTH_ORANGE EQU $99
COLOR_BOTH_PINK EQU $BB
COLOR_BOTH_LIGHTGREEN EQU $CC
COLOR_BOTH_YELLOW EQU $DD
COLOR_BOTH_AQUA EQU $EE
COLOR_BOTH_WHITE EQU $FF
AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011
AUX_BOTH_GREY EQU $AA ; 1010 1010