space_bars: more code moving

This commit is contained in:
Vince Weaver 2019-06-13 21:32:14 -04:00
parent f26790dd8b
commit 543fc1004d
6 changed files with 131 additions and 18 deletions

View File

@ -16,10 +16,11 @@ space_bars.dsk: SPACE_BARS HELLO
SPACE_BARS: space_bars.o
ld65 -o SPACE_BARS space_bars.o -C ../linker_scripts/apple2_4000.inc
space_bars.o: space_bars.s instructions.s game.s \
space_bars.o: space_bars.s instructions.s \
level3_earth.s level6_saturn.s \
game_over.s gr_copy.s text_print.s title.s \
spacebars_title.inc screen_split.s \
sprites.s sprites_table.s sprites_screen.s \
sprites_table.s sprites_screen.s \
vapor_lock.s delay_a.s lz4_decode.s SB_BACKGROUNDC.BIN.lz4 \
keypress.s zp.inc hardware.inc
ca65 -o space_bars.o space_bars.s -l space_bars.lst

115
space_bars/gr_unrle.s Normal file
View File

@ -0,0 +1,115 @@
;=================
; load RLE image
;=================
; Output is BASH/BASL
; Input is in GBASH/GBASL
load_rle_gr:
lda #$0
tay ; init Y to 0
sta TEMP ; stores the xcoord
sta CV ; ycoord=0
jsr load_and_increment ; load xsize
sta CH
rle_loop:
jsr load_and_increment
cmp #$A1 ; if 0xa1
beq rle_done ; we are done
pha
and #$f0 ; mask
cmp #$a0 ; see if special AX
beq decompress_special
pla ; note, PLA sets flags!
ldx #$1 ; only want to print 1
bne decompress_run
decompress_special:
pla
and #$0f ; check if was A0
bne decompress_color ; if A0 need to read run, color
decompress_large:
jsr load_and_increment ; get run length
decompress_color:
tax ; put runlen into X
jsr load_and_increment ; get color
decompress_run:
rle_run_loop:
sta (BASL),y ; write out the value
inc BASL ; increment the pointer
bne rle_skip3 ; if wrapped
inc BASH ; then increment the high value
rle_skip3:
pha ; store colore for later
inc TEMP ; increment the X value
lda TEMP
cmp CH ; compare against the image width
bcc rle_not_eol ; if less then keep going
lda BASL ; cheat to avoid a 16-bit add
cmp #$a7 ; we are adding 0x58 to get
bcc rle_add_skip ; to the next line
inc BASH
rle_add_skip:
clc
adc #$58 ; actually do the 0x58 add
sta BASL ; and store it back
inc CV ; add 2 to ypos
inc CV ; each "line" is two high
lda CV ; load value
cmp #15 ; if it's greater than 14 it wraps
bcc rle_no_wrap ; Thanks Woz
lda #$0 ; we wrapped, so set to zero
sta CV
; when wrapping have to sub 0x3d8
sec ; this is a 16-bit subtract routine
lda BASL
sbc #$d8 ; LSB
sta BASL
lda BASH ; MSB
sbc #$3 ;
sta BASH
rle_no_wrap:
lda #$0 ; set X value back to zero
sta TEMP
rle_not_eol:
pla ; restore color
dex
bne rle_run_loop ; if not zero, keep looping
beq rle_loop ; and branch always
rle_done:
lda #$15 ; move the cursor somewhere sane
sta CV
rts
load_and_increment:
lda (GBASL),y ; load value ; 5?
inc GBASL ; 5?
bne lskip2 ; 2nt/3
inc GBASH ; 5?
lskip2:
rts ; 6

View File

@ -1,2 +1,2 @@
10 PRINT "RASTERBARS IN SPACE V0.6"
10 PRINT "RASTERBARS IN SPACE V0.7"
100 PRINT CHR$ (4)"BRUN SPACE_BARS"

View File

@ -1,10 +1,3 @@
; TODO
; + merge with spacebars code
; + end of game, fly to the right
; + make harder as shoot more
; + end level with enough hits?
; Uses the 40x48d page1/page2 every-1-scanline pageflip mode
; self modifying code to get some extra colors (pseudo 40x192 mode)
@ -12,8 +5,12 @@
; by deater (Vince Weaver) <vince@deater.net>
; TODO:
; end level after a certain number of points
; track score properly
start_sprites:
level3_earth:
;===================
; init screen

View File

@ -1,7 +1,7 @@
;================================
; spacebars gameplay
;================================
game:
level6_saturn:
;===================
; init screen

View File

@ -37,7 +37,7 @@ view_title:
; EARTH: 40x192 sprites
;=============================
jsr start_sprites
jsr level3_earth
lda GAME_OVER
bne game_over_man
@ -46,7 +46,7 @@ view_title:
; SATURN: Rasterbars
;============================
jsr game
jsr level6_saturn
;==================
; Game Over
@ -65,12 +65,12 @@ loop_forever:
.include "gr_offsets.s"
.include "../asm_routines/gr_unrle.s"
.include "../asm_routines/keypress.s"
.include "gr_unrle.s"
.include "keypress.s"
.include "gr_copy.s"
.include "title.s"
.include "instructions.s"
.include "game.s"
.include "level6_saturn.s"
.include "text_print.s"
.include "game_over.s"
.align $100
@ -85,4 +85,4 @@ loop_forever:
.include "mode7_sprites.inc"
.align $100
.include "sprites.s"
.include "level3_earth.s"