mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-11-19 12:32:35 +00:00
chiptune/mode7: update rasterbars code comments
This commit is contained in:
parent
4efc30a019
commit
af0d298dbe
@ -66,19 +66,19 @@ init_rows:
|
|||||||
|
|
||||||
ldy SCREEN_Y ; 3
|
ldy SCREEN_Y ; 3
|
||||||
|
|
||||||
lda #COLOR_BOTH_DARKBLUE ; red ; 2
|
lda #COLOR_BOTH_DARKBLUE ; d. blue ; 2
|
||||||
jsr set_row_color ; 6+136
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_MEDIUMBLUE ; red ; 2
|
lda #COLOR_BOTH_MEDIUMBLUE ; m.blue ; 2
|
||||||
jsr set_row_color ; 6+136
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_AQUA ; red ; 2
|
lda #COLOR_BOTH_AQUA ; aqua ; 2
|
||||||
jsr set_row_color ; 6+136
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_PINK ; red ; 2
|
lda #COLOR_BOTH_PINK ; pink ; 2
|
||||||
jsr set_row_color ; 6+136
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_RED ; red ; 2
|
lda #COLOR_BOTH_RED ; red ; 2
|
||||||
jsr set_row_color ; 6+136
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
;==============
|
;==============
|
||||||
@ -96,7 +96,7 @@ draw_rows_loop:
|
|||||||
sta COLOR ; 3
|
sta COLOR ; 3
|
||||||
|
|
||||||
sty TEMPY ; 3
|
sty TEMPY ; 3
|
||||||
tya ; 2
|
tya ; y*2 ; 2
|
||||||
asl ; 2
|
asl ; 2
|
||||||
tay ; 2
|
tay ; 2
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
; Not quite a raster-bar, but why not
|
; Not quite a raster-bar, but why not
|
||||||
|
|
||||||
|
; Turns out this is quite the CPU hog.
|
||||||
|
; Optimized a bit based on the version in the chiptune player
|
||||||
|
|
||||||
;===========
|
;===========
|
||||||
; CONSTANTS
|
; CONSTANTS
|
||||||
;===========
|
;===========
|
||||||
@ -20,42 +23,47 @@ draw_rasters:
|
|||||||
|
|
||||||
; clear rows
|
; clear rows
|
||||||
|
|
||||||
ldy #(NUM_ROWS-1) ; 2
|
ldy #(NUM_ROWS-1) ; 2
|
||||||
lda #0 ; 2
|
lda #0 ; 2
|
||||||
|
|
||||||
init_rows:
|
init_rows:
|
||||||
sta row_color,Y ; 5
|
sta row_color,Y ; 5
|
||||||
dey ; 2
|
dey ; 2
|
||||||
bpl init_rows ; 2nt/3
|
bpl init_rows ; 2nt/3
|
||||||
|
;================
|
||||||
|
; 4+(10*20) = 204
|
||||||
|
; could be 82 if unroll
|
||||||
|
; at 6*code size
|
||||||
;================
|
;================
|
||||||
; set colors
|
; set colors
|
||||||
|
|
||||||
lda #COLOR_BOTH_AQUA ; aqua
|
ldy SCREEN_Y ; 3
|
||||||
ldy SCREEN_Y
|
|
||||||
jsr set_row_color
|
|
||||||
|
|
||||||
lda #COLOR_BOTH_MEDIUMBLUE ; medium blue
|
lda #COLOR_BOTH_AQUA ; aqua ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_LIGHTGREEN ; light green
|
lda #COLOR_BOTH_MEDIUMBLUE ; medium blue ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_DARKGREEN ; green
|
lda #COLOR_BOTH_LIGHTGREEN ; light green ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_YELLOW ; yellow
|
lda #COLOR_BOTH_DARKGREEN ; green ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_ORANGE ; orange
|
lda #COLOR_BOTH_YELLOW ; yellow ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_PINK ; pink
|
lda #COLOR_BOTH_ORANGE ; orange ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
lda #COLOR_BOTH_RED ; red
|
lda #COLOR_BOTH_PINK ; pink ; 2
|
||||||
jsr set_row_color
|
jsr set_row_color ; 6+136
|
||||||
|
|
||||||
|
lda #COLOR_BOTH_RED ; red ; 2
|
||||||
|
jsr set_row_color ; 6+136
|
||||||
|
;======================
|
||||||
|
; 3+(8*144) = 1155
|
||||||
;=================
|
;=================
|
||||||
; draw rows
|
; draw rows
|
||||||
|
|
||||||
@ -66,34 +74,52 @@ draw_rows_loop:
|
|||||||
|
|
||||||
sta COLOR ; 3
|
sta COLOR ; 3
|
||||||
|
|
||||||
|
sty TEMPY ; 3
|
||||||
tya ; 2
|
tya ; 2
|
||||||
pha ; 3
|
asl ; y*2 ; 2
|
||||||
asl ; 2
|
tay ; 2
|
||||||
|
|
||||||
|
; hlin_setup inlined
|
||||||
|
|
||||||
|
lda gr_offsets,Y ; lookup low-res memory address ; 4
|
||||||
|
sta GBASL ; 3
|
||||||
|
iny ; 2
|
||||||
|
lda gr_offsets,Y ; 4
|
||||||
|
clc ; 2
|
||||||
|
adc DRAW_PAGE ; add in draw page offset ; 3
|
||||||
|
sta GBASH ; 3
|
||||||
|
|
||||||
ldy #39 ; 2
|
ldy #39 ; 2
|
||||||
sty V2 ; 3
|
lda COLOR ; 3
|
||||||
ldy #0 ; 2
|
double_loop:
|
||||||
jsr hlin_double ; hlin y,V2 at A ; 63+(X*16)
|
sta (GBASL),Y ; 6
|
||||||
pla ; 4
|
dey ; 2
|
||||||
tay ; 2
|
bpl double_loop ; 2nt/3
|
||||||
|
|
||||||
|
ldy TEMPY ; 3
|
||||||
|
|
||||||
draw_rows_skip:
|
draw_rows_skip:
|
||||||
dey ; 2
|
dey ; 2
|
||||||
bpl draw_rows_loop ; 2
|
bpl draw_rows_loop ; 2nt/3
|
||||||
|
;======================
|
||||||
|
; 2+20*(53+11*40)=9862
|
||||||
|
; *note* worst case
|
||||||
|
|
||||||
;==================
|
;==================
|
||||||
; update y pointer
|
; update y pointer
|
||||||
;==================
|
;==================
|
||||||
ldy SCREEN_Y
|
ldy SCREEN_Y ; 3
|
||||||
iny
|
iny ; 2
|
||||||
cpy #ELEMENTS
|
cpy #ELEMENTS ; 2
|
||||||
bne not_there
|
bne not_there ; 2nt/3
|
||||||
ldy #0
|
ldy #0 ; 2
|
||||||
not_there:
|
not_there:
|
||||||
sty SCREEN_Y
|
sty SCREEN_Y ; 3
|
||||||
|
|
||||||
|
|
||||||
rts
|
rts ; 6
|
||||||
|
;=============
|
||||||
|
; 24
|
||||||
|
|
||||||
;===================
|
;===================
|
||||||
;===================
|
;===================
|
||||||
@ -106,62 +132,64 @@ not_there:
|
|||||||
; A, X trashed
|
; A, X trashed
|
||||||
|
|
||||||
set_row_color:
|
set_row_color:
|
||||||
sta COLOR
|
sta COLOR ; 3
|
||||||
tya ; wrap y offset
|
tya ; wrap y offset ; 2
|
||||||
and #(ELEMENTS-1)
|
and #(ELEMENTS-1) ; 2
|
||||||
tax
|
tax ; 2
|
||||||
|
|
||||||
lda fine_sine,X ; lookup sine value
|
lda fine_sine,X ; lookup sine value ; 4
|
||||||
; pre-shifted right by 4, sign-extended
|
; pre-shifted right by 4, sign-extended
|
||||||
|
; 18 added to center
|
||||||
clc
|
|
||||||
adc #18 ; add in 18 to center on screen
|
|
||||||
|
|
||||||
sin_no_more:
|
sin_no_more:
|
||||||
|
|
||||||
pha ; save row value
|
pha ; save row value ; 3
|
||||||
jsr put_color ; put color at row
|
jsr put_color ; put color at row ; 6+44
|
||||||
pla ; restore row value
|
pla ; restore row value ; 4
|
||||||
|
|
||||||
clc ; increment row value
|
clc ; increment row value ; 2
|
||||||
adc #1
|
adc #1 ; 2
|
||||||
|
|
||||||
jsr put_color ; put color at row
|
jsr put_color ; put color at row ; 6+44
|
||||||
|
|
||||||
iny ; increment for next time
|
iny ; increment for next time ; 2
|
||||||
|
|
||||||
rts
|
|
||||||
|
|
||||||
|
rts ; 6
|
||||||
|
;============
|
||||||
|
; 132
|
||||||
;==================
|
;==================
|
||||||
; put_color
|
; put_color
|
||||||
;==================
|
;==================
|
||||||
; A = row to set color of
|
; A = row to set color of
|
||||||
; A trashed
|
; A trashed
|
||||||
put_color:
|
put_color:
|
||||||
clc
|
clc ; 2
|
||||||
ror ; row/2, with even/odd in carry
|
ror ; row/2, with even/odd in carry ; 2
|
||||||
tax ; put row/2 in X
|
tax ; put row/2 in X ; 2
|
||||||
|
|
||||||
bcc even_line ; if even, skip to even
|
bcc even_line ; if even, skip to even ; 2nt/3
|
||||||
odd_line:
|
odd_line:
|
||||||
lda #$f0 ; load mask for odd
|
lda #$f0 ; load mask for odd ; 2
|
||||||
bcs finish_line
|
bcs finish_line ; 2nt/3
|
||||||
even_line:
|
even_line:
|
||||||
lda #$0f ; load mask for even
|
lda #$0f ; load mask for even ; 2
|
||||||
finish_line:
|
finish_line:
|
||||||
sta MASK
|
sta MASK ; 3
|
||||||
|
|
||||||
and COLOR ; mask off color
|
and COLOR ; mask off color ; 3
|
||||||
sta COLOR2 ; store for later
|
sta COLOR2 ; store for later ; 3
|
||||||
|
|
||||||
lda MASK
|
lda MASK ; 3
|
||||||
eor #$ff ; invert mask
|
eor #$ff ; invert mask ; 2
|
||||||
and row_color,X ; load existing color
|
and row_color,X ; load existing color ; 4
|
||||||
|
|
||||||
ora COLOR2 ; combine
|
ora COLOR2 ; combine ; 3
|
||||||
sta row_color,X ; store back
|
sta row_color,X ; store back ; 5
|
||||||
|
|
||||||
rts
|
rts ; 6
|
||||||
|
|
||||||
|
;============
|
||||||
|
; 44
|
||||||
|
|
||||||
;======================
|
;======================
|
||||||
; some arrays
|
; some arrays
|
||||||
@ -171,74 +199,77 @@ 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
|
; arithmatically shifted right by 4, sign extended, added 18 to center
|
||||||
|
|
||||||
; FIXME: exploit symmetry and get rid of 3/4 of this table
|
; FIXME: exploit symmetry and get rid of 3/4 of this table
|
||||||
; possibly not worth the extra code
|
; possibly not worth the extra code
|
||||||
fine_sine:
|
fine_sine:
|
||||||
.byte $00 ; 0.000000
|
.byte $00+18 ; 0.000000 ; a[y] 00..10
|
||||||
.byte $01 ; 0.098017
|
.byte $01+18 ; 0.098017 ; a[32-y] 11..20
|
||||||
.byte $03 ; 0.195090
|
.byte $03+18 ; 0.195090 ; ~a[y-33] 21..30
|
||||||
.byte $04 ; 0.290285
|
.byte $04+18 ; 0.290285 ; ~a[64-y] 31..3f
|
||||||
.byte $06 ; 0.382683
|
.byte $06+18 ; 0.382683
|
||||||
.byte $07 ; 0.471397
|
.byte $07+18 ; 0.471397
|
||||||
.byte $08 ; 0.555570
|
.byte $08+18 ; 0.555570
|
||||||
.byte $0A ; 0.634393
|
.byte $0A+18 ; 0.634393
|
||||||
.byte $0B ; 0.707107
|
.byte $0B+18 ; 0.707107
|
||||||
.byte $0C ; 0.773010
|
.byte $0C+18 ; 0.773010
|
||||||
.byte $0D ; 0.831470
|
.byte $0D+18 ; 0.831470
|
||||||
.byte $0E ; 0.881921
|
.byte $0E+18 ; 0.881921
|
||||||
.byte $0E ; 0.923880
|
.byte $0E+18 ; 0.923880
|
||||||
.byte $0F ; 0.956940
|
.byte $0F+18 ; 0.956940
|
||||||
.byte $0F ; 0.980785
|
.byte $0F+18 ; 0.980785
|
||||||
.byte $0F ; 0.995185
|
.byte $0F+18 ; 0.995185
|
||||||
.byte $0F ; 1.000000
|
|
||||||
.byte $0F ; 0.995185
|
|
||||||
.byte $0F ; 0.980785
|
|
||||||
.byte $0F ; 0.956940
|
|
||||||
.byte $0E ; 0.923880
|
|
||||||
.byte $0E ; 0.881921
|
|
||||||
.byte $0D ; 0.831470
|
|
||||||
.byte $0C ; 0.773010
|
|
||||||
.byte $0B ; 0.707107
|
|
||||||
.byte $0A ; 0.634393
|
|
||||||
.byte $08 ; 0.555570
|
|
||||||
.byte $07 ; 0.471397
|
|
||||||
.byte $06 ; 0.382683
|
|
||||||
.byte $04 ; 0.290285
|
|
||||||
.byte $03 ; 0.195090
|
|
||||||
.byte $01 ; 0.098017
|
|
||||||
.byte $00 ; 0.000000
|
|
||||||
|
|
||||||
.byte $FE ; -0.098017
|
.byte $0F+18 ; 1.000000
|
||||||
.byte $FC ; -0.195090
|
|
||||||
.byte $FB ; -0.290285
|
.byte $0F+18 ; 0.995185
|
||||||
.byte $F9 ; -0.382683
|
.byte $0F+18 ; 0.980785
|
||||||
.byte $F8 ; -0.471397
|
.byte $0F+18 ; 0.956940
|
||||||
.byte $F7 ; -0.555570
|
.byte $0E+18 ; 0.923880
|
||||||
.byte $F5 ; -0.634393
|
.byte $0E+18 ; 0.881921
|
||||||
.byte $F4 ; -0.707107
|
.byte $0D+18 ; 0.831470
|
||||||
.byte $F3 ; -0.773010
|
.byte $0C+18 ; 0.773010
|
||||||
.byte $F2 ; -0.831470
|
.byte $0B+18 ; 0.707107
|
||||||
.byte $F1 ; -0.881921
|
.byte $0A+18 ; 0.634393
|
||||||
.byte $F1 ; -0.923880
|
.byte $08+18 ; 0.555570
|
||||||
.byte $F0 ; -0.956940
|
.byte $07+18 ; 0.471397
|
||||||
.byte $F0 ; -0.980785
|
.byte $06+18 ; 0.382683
|
||||||
.byte $F0 ; -0.995185
|
.byte $04+18 ; 0.290285
|
||||||
.byte $F0 ; -1.000000
|
.byte $03+18 ; 0.195090
|
||||||
.byte $F0 ; -0.995185
|
.byte $01+18 ; 0.098017
|
||||||
.byte $F0 ; -0.980785
|
|
||||||
.byte $F0 ; -0.956940
|
.byte $00+18 ; 0.000000
|
||||||
.byte $F1 ; -0.923880
|
.byte ($FE+18)&$ff ; -0.098017
|
||||||
.byte $F1 ; -0.881921
|
.byte ($FC+18)&$ff ; -0.195090
|
||||||
.byte $F2 ; -0.831470
|
.byte ($FB+18)&$ff ; -0.290285
|
||||||
.byte $F3 ; -0.773010
|
.byte ($F9+18)&$ff ; -0.382683
|
||||||
.byte $F4 ; -0.707107
|
.byte ($F8+18)&$ff ; -0.471397
|
||||||
.byte $F5 ; -0.634393
|
.byte ($F7+18)&$ff ; -0.555570
|
||||||
.byte $F7 ; -0.555570
|
.byte ($F5+18)&$ff ; -0.634393
|
||||||
.byte $F8 ; -0.471397
|
.byte ($F4+18)&$ff ; -0.707107
|
||||||
.byte $F9 ; -0.382683
|
.byte ($F3+18)&$ff ; -0.773010
|
||||||
.byte $FB ; -0.290285
|
.byte ($F2+18)&$ff ; -0.831470
|
||||||
.byte $FC ; -0.195090
|
.byte ($F1+18)&$ff ; -0.881921
|
||||||
.byte $FE ; -0.098017
|
.byte ($F1+18)&$ff ; -0.923880
|
||||||
|
.byte ($F0+18)&$ff ; -0.956940
|
||||||
|
.byte ($F0+18)&$ff ; -0.980785
|
||||||
|
.byte ($F0+18)&$ff ; -0.995185
|
||||||
|
|
||||||
|
.byte ($F0+18)&$ff ; -1.000000
|
||||||
|
.byte ($F0+18)&$ff ; -0.995185
|
||||||
|
.byte ($F0+18)&$ff ; -0.980785
|
||||||
|
.byte ($F0+18)&$ff ; -0.956940
|
||||||
|
.byte ($F1+18)&$ff ; -0.923880
|
||||||
|
.byte ($F1+18)&$ff ; -0.881921
|
||||||
|
.byte ($F2+18)&$ff ; -0.831470
|
||||||
|
.byte ($F3+18)&$ff ; -0.773010
|
||||||
|
.byte ($F4+18)&$ff ; -0.707107
|
||||||
|
.byte ($F5+18)&$ff ; -0.634393
|
||||||
|
.byte ($F7+18)&$ff ; -0.555570
|
||||||
|
.byte ($F8+18)&$ff ; -0.471397
|
||||||
|
.byte ($F9+18)&$ff ; -0.382683
|
||||||
|
.byte ($FB+18)&$ff ; -0.290285
|
||||||
|
.byte ($FC+18)&$ff ; -0.195090
|
||||||
|
.byte ($FE+18)&$ff ; -0.098017
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user