16 |
;463 self modifying pointer in mainly_horizontal (38.35) |
;463 self modifying pointer in mainly_horizontal (38.35) |
17 |
;459 self modifying pointer in mainly_vertical (37.99) |
;459 self modifying pointer in mainly_vertical (37.99) |
18 |
;459 a little tweak to very_horizontal (37.94) |
;459 a little tweak to very_horizontal (37.94) |
19 |
;451 refactored to make x-direction always positive (37.16) |
;451 refactored to make x-direction always positive (37.07) |
20 |
|
|
21 |
; TODOs: |
; TODOs: |
22 |
; + chunking (-35) |
; + chunking (-35) |
25 |
; x mainly_horizontal (won't work) |
; x mainly_horizontal (won't work) |
26 |
; + mainly_vertical (-9) |
; + mainly_vertical (-9) |
27 |
; o optimizing for space (-2 tables and one alignment page) |
; o optimizing for space (-2 tables and one alignment page) |
28 |
; - optimize horizontal (merge with very_horizontal) |
; + optimize horizontal (merge with very_horizontal) |
29 |
; o optimize vertical |
; o optimize vertical |
30 |
; + correct branch taken percentages |
; + correct branch taken percentages |
31 |
; + always draw left to right and patch y-direction (-8) |
; + always draw left to right and patch y-direction (-8) |
57 |
#define X_SIZE 240 |
#define X_SIZE 240 |
58 |
#define ROW_SIZE X_SIZE/BYTE_PIXEL |
#define ROW_SIZE X_SIZE/BYTE_PIXEL |
59 |
|
|
|
#define _NOP $ea |
|
|
#define _INX $e8 |
|
|
#define _DEX $ca |
|
60 |
#define _INY $c8 |
#define _INY $c8 |
61 |
#define _DEY $88 |
#define _DEY $88 |
|
#define _ASL $0a |
|
|
#define _LSR $4a |
|
62 |
#define _INC_ZP $e6 |
#define _INC_ZP $e6 |
63 |
#define _DEC_ZP $c6 |
#define _DEC_ZP $c6 |
64 |
#define _INC_ABS $ee |
#define _INC_ABS $ee |
65 |
#define _DEC_ABS $ce |
#define _DEC_ABS $ce |
|
#define _STA_ZP $85 |
|
|
#define _CPY_IMM $c0 |
|
66 |
#define _ADC_IMM $69 |
#define _ADC_IMM $69 |
67 |
#define _SBC_IMM $e9 |
#define _SBC_IMM $e9 |
68 |
#define _BCC $90 |
#define _BCC $90 |
76 |
; .dsb 256-(*&255) |
; .dsb 256-(*&255) |
77 |
|
|
78 |
;********************************************************** |
;********************************************************** |
|
draw_totaly_horizontal_8 |
|
|
.( |
|
|
; here we have DY in Y, and the OPCODE in X |
|
|
ldx _OtherPixelX |
|
|
inx |
|
|
stx _patch_cpx+1 |
|
|
ldx _CurrentPixelX |
|
|
; |
|
|
; draw loop |
|
|
; |
|
|
outer_loop |
|
|
ldy _TableDiv6,x ; 4 |
|
|
lda _TableBit6Reverse,x ; 4 |
|
|
OPP (tmp0),y ; 5 |
|
|
sta (tmp0),y ; 6 = 19 |
|
|
|
|
|
inx ; 2 |
|
|
_patch_cpx |
|
|
cpx #00 ; 2 At the endpoint yet? |
|
|
bne outer_loop ; 2 |
|
|
rts |
|
|
.) |
|
|
|
|
|
;********************************************************** |
|
79 |
; |
; |
80 |
; Expects the following variables to be set when called: |
; Expects the following variables to be set when called: |
81 |
; _CurrentPixelX |
; _CurrentPixelX |
127 |
sec |
sec |
128 |
lda _CurrentPixelY |
lda _CurrentPixelY |
129 |
sbc _OtherPixelY |
sbc _OtherPixelY |
130 |
beq draw_totaly_horizontal_8 |
; beq horizontal |
131 |
ldx #_DEY |
ldx #_DEY |
132 |
bcs cur_bigger |
bcs cur_bigger |
133 |
|
|
143 |
tay |
tay |
144 |
jmp alignIt |
jmp alignIt |
145 |
|
|
146 |
|
;horizontal |
147 |
|
; jmp draw_totally_horizontal_8 |
148 |
|
|
149 |
.dsb 256-(*&255) |
.dsb 256-(*&255) |
150 |
|
|
151 |
alignIt |
alignIt |
366 |
asl |
asl |
367 |
adc _TableDiv6,x |
adc _TableDiv6,x |
368 |
asl |
asl |
369 |
sta save_a ; save_a = _CurrentPixelX % 6 |
; clc |
370 |
lda _CurrentPixelX |
adc #BYTE_PIXEL;-1 |
371 |
sec |
; sec |
372 |
sbc save_a |
sbc _CurrentPixelX |
|
sta save_a |
|
|
lda #BYTE_PIXEL-1 |
|
|
sbc save_a |
|
373 |
tax |
tax |
374 |
lda Pot2PTbl,x |
lda Pot2PTbl,x |
375 |
sta chunk |
sta chunk |
377 |
; patch the code: |
; patch the code: |
378 |
plp |
plp |
379 |
beq doIny |
beq doIny |
380 |
|
; no y-direction? |
381 |
|
lda dy |
382 |
|
beq draw_totally_horizontal_8 |
383 |
; negative y-direction |
; negative y-direction |
384 |
dec _patch_dy0+1 |
dec _patch_dy0+1 |
385 |
|
|
436 |
bne contColumn ; 3 = 8 |
bne contColumn ; 3 = 8 |
437 |
; average: 30.03 |
; average: 30.03 |
438 |
;---------------------------------------------------------- |
;---------------------------------------------------------- |
439 |
|
draw_totally_horizontal_8 |
440 |
|
lda #1 |
441 |
|
sta _patch_dy2+1 |
442 |
|
lda dx |
443 |
|
eor #$ff ; = -dx |
444 |
|
clc |
445 |
|
bcc loopXEnd |
446 |
|
;---------------------------------------------------------- |
447 |
loopY |
loopY |
448 |
lda save_a ; 3 |
lda save_a ; 3 |
449 |
dec dy ; 5 all but one vertical segments drawn? |
dec dy ; 5 all but one vertical segments drawn? |
465 |
sta save_a ; 3 = 5 |
sta save_a ; 3 = 5 |
466 |
|
|
467 |
; plot the last bits of current segment: |
; plot the last bits of current segment: |
|
_patch_pot1 |
|
468 |
lda Pot2PTbl,x ; 4 |
lda Pot2PTbl,x ; 4 |
469 |
eor chunk ; 3 |
eor chunk ; 3 |
470 |
OPP (tmp0),y ; 5 |
OPP (tmp0),y ; 5 |
471 |
sta (tmp0),y ; 6 |
sta (tmp0),y ; 6 |
|
_patch_pot2 |
|
472 |
lda Pot2PTbl,x ; 4 |
lda Pot2PTbl,x ; 4 |
473 |
sta chunk ; 3 = 25 |
sta chunk ; 3 = 25 |
474 |
|
|
493 |
;---------------------------------------------------------- |
;---------------------------------------------------------- |
494 |
exitLoop |
exitLoop |
495 |
; draw the last horizontal line segment: |
; draw the last horizontal line segment: |
496 |
clc |
clc |
497 |
adc lastSum ; 3 |
adc lastSum ; 3 |
498 |
loopXEnd |
loopXEnd |
499 |
dex ; 2 |
dex ; 2 |
504 |
bcc loopXEnd ; 2/3= 4/5 ~38.2% taken |
bcc loopXEnd ; 2/3= 4/5 ~38.2% taken |
505 |
|
|
506 |
; plot last chunk: |
; plot last chunk: |
|
_patch_pot3 |
|
507 |
lda Pot2PTbl,x ; 4 |
lda Pot2PTbl,x ; 4 |
508 |
eor chunk ; 3 |
eor chunk ; 3 |
509 |
OPP (tmp0),y ; 5 |
OPP (tmp0),y ; 5 |
622 |
inc _patch_ptr1+2 ; 6 |
inc _patch_ptr1+2 ; 6 |
623 |
_patch_clc1 |
_patch_clc1 |
624 |
clc ; 2 |
clc ; 2 |
625 |
bne contHiPtr ; 3 |
bne contHiPtr ; 3 = 17 |
626 |
;---------------------------------------------------------- |
;---------------------------------------------------------- |
627 |
loopY |
loopY |
628 |
sta save_a ; 3 |
sta save_a ; 3 |
640 |
tay ; 2 |
tay ; 2 |
641 |
_patch_bcs1 |
_patch_bcs1 |
642 |
bcs incHiPtr ; 2/20 ~15.6% taken |
bcs incHiPtr ; 2/20 ~15.6% taken |
643 |
contHiPtr ; = 11.00 average |
contHiPtr ; = 10.81 average |
644 |
lda save_a ; 3 |
lda save_a ; 3 |
645 |
_patch_dx1 |
_patch_dx1 |
646 |
adc #00 ; 2 +DX |
adc #00 ; 2 +DX |
659 |
dex ; 2 At the endpoint yet? |
dex ; 2 At the endpoint yet? |
660 |
bne loopX ; 2/3= 4/5 |
bne loopX ; 2/3= 4/5 |
661 |
|
|
662 |
; x ,y++: 34.00 (41.4%) |
; x ,y++: 33.81 (41.4%) |
663 |
; x++,y++: 48.68 (58.6%) |
; x++,y++: 48.49 (58.6%) |
664 |
; average: 42.60 |
; average: 42.41 |
665 |
|
|
666 |
; draw the last vertical line segment: |
; draw the last vertical line segment: |
667 |
ldx _patch_ptr0+2 ; 4 |
ldx _patch_ptr0+2 ; 4 |
709 |
; *** total timings: *** |
; *** total timings: *** |
710 |
; draw_very_horizontal_8 (29.5%): 25.55 (was 25.73) |
; draw_very_horizontal_8 (29.5%): 25.55 (was 25.73) |
711 |
; draw_mainly_horizontal_8 (20.5%): 40.62 (was 41.30) |
; draw_mainly_horizontal_8 (20.5%): 40.62 (was 41.30) |
712 |
; draw_mainly_vertical_8 (50.0%): 42.60 (was 43.77) |
; draw_mainly_vertical_8 (50.0%): 42.41 (was 43.77) |
713 |
;---------------------------------------- |
;---------------------------------------- |
|
; total average (100.0%): 37.16 (was 37.94) |
|
714 |
|
; total average (100.0%): 37.07 (was 37.94) |