mode7_demo: merge in the rasterbars

This commit is contained in:
Vince Weaver 2018-01-31 01:15:47 -05:00
parent cbceb40560
commit b87d7e433c
5 changed files with 136 additions and 218 deletions

Binary file not shown.

View File

@ -223,4 +223,4 @@ title_routine:
.include "deater.scrolltext" .include "deater.scrolltext"
.include "a2.scrolltext" .include "a2.scrolltext"
.include "starfield_demo.s" .include "starfield_demo.s"
.include "rasterbars.s"

View File

@ -1,126 +1,85 @@
; Not quite a raster-bar, but why not ; Not quite a raster-bar, but why not
.include "zp.inc"
;=========== ;===========
; CONSTANTS ; CONSTANTS
;=========== ;===========
ELEMENTS EQU 64 ELEMENTS EQU 64
NUM_ROWS EQU 20
;===================== ;=====================
; Rasterbars ; Rasterbars
;===================== ;=====================
;================================
; Clear screen and setup graphics
;================================
jsr clear_screens ; clear top/bottom of page 0/1
jsr set_gr_page0
;===============
; Init Variables
;===============
lda #0 ; 2
sta DRAW_PAGE ; 3
sta SCREEN_Y
;=========================== ;===========================
;=========================== ;===========================
; Main Loop ; Main Loop
;=========================== ;===========================
;=========================== ;===========================
raster_loop: draw_rasters:
; clear rows ; clear rows
ldy #19 ; 2 ldy #(NUM_ROWS-1) ; 2
lda #0 lda #0 ; 2
init_rows:
sta row_color,Y
dey
bpl init_rows
jsr clear_top init_rows:
sta row_color,Y ; 5
dey ; 2
bpl init_rows ; 2nt/3
;================ ;================
; set colors ; set colors
lda #COLOR_BOTH_AQUA ; aqua lda #COLOR_BOTH_AQUA ; aqua
sta COLOR
ldy SCREEN_Y ldy SCREEN_Y
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_MEDIUMBLUE ; medium blue lda #COLOR_BOTH_MEDIUMBLUE ; medium blue
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_LIGHTGREEN ; light green lda #COLOR_BOTH_LIGHTGREEN ; light green
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_DARKGREEN ; green lda #COLOR_BOTH_DARKGREEN ; green
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_YELLOW ; yellow lda #COLOR_BOTH_YELLOW ; yellow
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_ORANGE ; orange lda #COLOR_BOTH_ORANGE ; orange
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_PINK ; pink lda #COLOR_BOTH_PINK ; pink
sta COLOR
iny
jsr set_row_color jsr set_row_color
lda #COLOR_BOTH_RED ; red lda #COLOR_BOTH_RED ; red
sta COLOR
iny
jsr set_row_color jsr set_row_color
;================= ;=================
; draw rows ; draw rows
ldy #19 ldy #(NUM_ROWS-1) ; 2
draw_rows_loop: draw_rows_loop:
lda row_color,Y lda row_color,Y ; 5
sta COLOR beq draw_rows_skip ; skip if black ; 2nt/3
tya sta COLOR ; 3
pha
asl
tya ; 2
pha ; 3
asl ; 2
ldy #39 ; 2 ldy #39 ; 2
sty V2 ; 3 sty V2 ; 3
ldy #0 ; 2 ldy #0 ; 2
jsr hlin_double ; hlin y,V2 at A ; 63+(X*16) jsr hlin_double ; hlin y,V2 at A ; 63+(X*16)
pla ; 4 pla ; 4
tay tay ; 2
dey draw_rows_skip:
bpl draw_rows_loop dey ; 2
bpl draw_rows_loop ; 2
;==================
; flip pages
;==================
jsr page_flip ; 6
;==================
; delay?
;==================
;================== ;==================
; update y pointer ; update y pointer
@ -134,127 +93,76 @@ not_there:
sty SCREEN_Y sty SCREEN_Y
;================== rts
; loop forever
;==================
jmp raster_loop ; 3
;===================
;=================== ;===================
; set_row_color ; set_row_color
;=================== ;===================
; color in COLOR ;===================
; color in A
; Y=offset ; Y=offset
; Y preserved? ; Y incremented
set_row_color: ; A, X trashed
tya ; wrap y offset set_row_color:
sta COLOR
tya ; wrap y offset
and #(ELEMENTS-1) and #(ELEMENTS-1)
tax tax
lda fine_sine,X ; lookup sign value lda fine_sine,X ; lookup sine value
cpx #33 ; check if > pi and ; pre-shifted right by 4, sign-extended
bpl sin_negative ; need to make negative
sin_positive:
clc ; shift right by 4, zero-extend
ror
clc
ror
clc
ror
clc
ror
clc clc
adc #18 ; add in 18 to center on screen adc #18 ; add in 18 to center on screen
; lsr ; shift once more
jmp sin_no_more
; FIXME: precalculate as we shift same each time
sin_negative:
sec
ror
sec
ror
sec
ror
sec
ror
clc
adc #18
; lsr
sin_no_more: sin_no_more:
pha
lsr
tax
pla
pha
jsr put_color pha ; save row value
jsr put_color ; put color at row
pla ; restore row value
pla clc ; increment row value
tax adc #1
cpy 32 jsr put_color ; put color at row
beq no_inc
bmi yes_inc
dex iny ; increment for next time
dex
yes_inc:
inx
no_inc:
txa ; horrific
pha
lsr
tax
pla
jsr put_color
rts rts
;==================
; put_color
;==================
; A = row to set color of
; A trashed
put_color: put_color:
and #$1 ; see if even or odd clc
beq even_line ror ; row/2, with even/odd in carry
tax ; put row/2 in X
lda COLOR bcc even_line ; if even, skip to even
and #$f0 odd_line:
sta COLOR2 lda #$f0 ; load mask for odd
bcs finish_line
lda row_color,X
and #$0f
jmp done_line
even_line: even_line:
lda COLOR lda #$0f ; load mask for even
and #$0f finish_line:
sta COLOR2 sta MASK
lda row_color,X and COLOR ; mask off color
and #$f0 sta COLOR2 ; store for later
done_line: lda MASK
ora COLOR2 eor #$ff ; invert mask
sta row_color,X and row_color,X ; load existing color
ora COLOR2 ; combine
sta row_color,X ; store back
rts rts
;===============================================
; External modules
;===============================================
.include "../asm_routines/pageflip.s"
.include "../asm_routines/gr_setpage.s"
;.include "../asm_routines/keypress.s"
.include "../asm_routines/gr_offsets.s"
.include "../asm_routines/gr_fast_clear.s"
.include "../asm_routines/gr_hlin.s"
;====================== ;======================
; some arrays ; some arrays
;====================== ;======================
@ -263,69 +171,74 @@ row_color:
.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00
.byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00 .byte $00,$00,$00,$00,$00, $00,$00,$00,$00,$00
; arithmatically shifted right by 4
; FIXME: exploit symmetry and get rid of 3/4 of this table
; possibly not worth the extra code
fine_sine: fine_sine:
.byte $00 ; 0.000000 .byte $00 ; 0.000000
.byte $19 ; 0.098017 .byte $01 ; 0.098017
.byte $31 ; 0.195090 .byte $03 ; 0.195090
.byte $4A ; 0.290285 .byte $04 ; 0.290285
.byte $61 ; 0.382683 .byte $06 ; 0.382683
.byte $78 ; 0.471397 .byte $07 ; 0.471397
.byte $8E ; 0.555570 .byte $08 ; 0.555570
.byte $A2 ; 0.634393 .byte $0A ; 0.634393
.byte $B5 ; 0.707107 .byte $0B ; 0.707107
.byte $C5 ; 0.773010 .byte $0C ; 0.773010
.byte $D4 ; 0.831470 .byte $0D ; 0.831470
.byte $E1 ; 0.881921 .byte $0E ; 0.881921
.byte $EC ; 0.923880 .byte $0E ; 0.923880
.byte $F4 ; 0.956940 .byte $0F ; 0.956940
.byte $FB ; 0.980785 .byte $0F ; 0.980785
.byte $FE ; 0.995185 .byte $0F ; 0.995185
.byte $FF ; 1.000000 .byte $0F ; 1.000000
.byte $FE ; 0.995185 .byte $0F ; 0.995185
.byte $FB ; 0.980785 .byte $0F ; 0.980785
.byte $F4 ; 0.956940 .byte $0F ; 0.956940
.byte $EC ; 0.923880 .byte $0E ; 0.923880
.byte $E1 ; 0.881921 .byte $0E ; 0.881921
.byte $D4 ; 0.831470 .byte $0D ; 0.831470
.byte $C5 ; 0.773010 .byte $0C ; 0.773010
.byte $B5 ; 0.707107 .byte $0B ; 0.707107
.byte $A2 ; 0.634393 .byte $0A ; 0.634393
.byte $8E ; 0.555570 .byte $08 ; 0.555570
.byte $78 ; 0.471397 .byte $07 ; 0.471397
.byte $61 ; 0.382683 .byte $06 ; 0.382683
.byte $4A ; 0.290285 .byte $04 ; 0.290285
.byte $31 ; 0.195090 .byte $03 ; 0.195090
.byte $19 ; 0.098017 .byte $01 ; 0.098017
.byte $00 ; 0.000000 .byte $00 ; 0.000000
.byte $E7 ; -0.098017
.byte $CF ; -0.195090 .byte $FE ; -0.098017
.byte $B6 ; -0.290285 .byte $FC ; -0.195090
.byte $9F ; -0.382683 .byte $FB ; -0.290285
.byte $88 ; -0.471397 .byte $F9 ; -0.382683
.byte $72 ; -0.555570 .byte $F8 ; -0.471397
.byte $5E ; -0.634393 .byte $F7 ; -0.555570
.byte $4B ; -0.707107 .byte $F5 ; -0.634393
.byte $3B ; -0.773010 .byte $F4 ; -0.707107
.byte $2C ; -0.831470 .byte $F3 ; -0.773010
.byte $1F ; -0.881921 .byte $F2 ; -0.831470
.byte $14 ; -0.923880 .byte $F1 ; -0.881921
.byte $0C ; -0.956940 .byte $F1 ; -0.923880
.byte $05 ; -0.980785 .byte $F0 ; -0.956940
.byte $02 ; -0.995185 .byte $F0 ; -0.980785
.byte $00 ; -1.000000 .byte $F0 ; -0.995185
.byte $02 ; -0.995185 .byte $F0 ; -1.000000
.byte $05 ; -0.980785 .byte $F0 ; -0.995185
.byte $0C ; -0.956940 .byte $F0 ; -0.980785
.byte $14 ; -0.923880 .byte $F0 ; -0.956940
.byte $1F ; -0.881921 .byte $F1 ; -0.923880
.byte $2C ; -0.831470 .byte $F1 ; -0.881921
.byte $3B ; -0.773010 .byte $F2 ; -0.831470
.byte $4B ; -0.707107 .byte $F3 ; -0.773010
.byte $5E ; -0.634393 .byte $F4 ; -0.707107
.byte $72 ; -0.555570 .byte $F5 ; -0.634393
.byte $88 ; -0.471397 .byte $F7 ; -0.555570
.byte $9F ; -0.382683 .byte $F8 ; -0.471397
.byte $B6 ; -0.290285 .byte $F9 ; -0.382683
.byte $CF ; -0.195090 .byte $FB ; -0.290285
.byte $E7 ; -0.098017 .byte $FC ; -0.195090
.byte $FE ; -0.098017

View File

@ -121,6 +121,7 @@ starfield_credits:
lda #0 ; 2 lda #0 ; 2
sta DRAW_PAGE ; 3 sta DRAW_PAGE ; 3
sta RANDOM_POINTER ; 3 sta RANDOM_POINTER ; 3
sta SCREEN_Y
; always multiply with low byte as zero ; always multiply with low byte as zero
sta NUM2L ; 3 sta NUM2L ; 3
sta FRAME_COUNT sta FRAME_COUNT
@ -154,6 +155,8 @@ starcredits_loop:
; draw the rasterbars ; draw the rasterbars
;==================== ;====================
jsr draw_rasters
;==================== ;====================
; draw the credits ; draw the credits
;==================== ;====================

View File

@ -177,8 +177,10 @@ COLOR_BOTH_MEDIUMBLUE EQU $66
COLOR_BOTH_LIGHTBLUE EQU $77 COLOR_BOTH_LIGHTBLUE EQU $77
COLOR_BOTH_BROWN EQU $88 COLOR_BOTH_BROWN EQU $88
COLOR_BOTH_ORANGE EQU $99 COLOR_BOTH_ORANGE EQU $99
COLOR_BOTH_PINK EQU $BB
COLOR_BOTH_LIGHTGREEN EQU $CC COLOR_BOTH_LIGHTGREEN EQU $CC
COLOR_BOTH_YELLOW EQU $DD COLOR_BOTH_YELLOW EQU $DD
COLOR_BOTH_AQUA EQU $EE
COLOR_BOTH_WHITE EQU $FF COLOR_BOTH_WHITE EQU $FF
AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011 AUX_BOTH_MEDIUMBLUE EQU $33 ; 0011 0011