second: re-arrange VLIN to slightly optimize replayer

not really worth the trouble
This commit is contained in:
Vince Weaver 2023-10-11 00:29:36 -04:00
parent 07377a0204
commit cae86499c9
4 changed files with 84 additions and 128 deletions

View File

@ -28,13 +28,13 @@ frame15: ; handmade / auto
.include "handmade/frame041.inc" ; 65 / 66 (1 byte)
.include "auto/frame042.inc" ; 92 / 78 (-14 bytes)
.include "handmade/frame043.inc" ; 233 / 273 (40 bytes)
.include "handmade/frame044.inc" ; 202 / 220 (18 bytes)
.include "handmade/frame044.inc" ; 199 / 220 (21 bytes)
.include "handmade/frame045.inc" ; 182 / 204 (22 bytes)
.include "handmade/frame046.inc" ; 172 / 174 (2 bytes)
.include "handmade/frame047.inc" ; 191 / 202 (11 bytes)
.include "handmade/frame048.inc" ; 219 / 226 (7 bytes)
.include "handmade/frame049.inc" ; 189 / 198 (9 bytes)
.include "handmade/frame050.inc" ; 264 / 288 (24 bytes)
.include "handmade/frame048.inc" ; 218 / 226 (8 bytes)
.include "handmade/frame049.inc" ; 186 / 198 (12 bytes)
.include "handmade/frame050.inc" ; 253 / 288 (35 bytes)
.include "auto/frame051.inc" ;
.include "auto/frame052.inc" ;
.include "auto/frame053.inc" ;

View File

@ -8,7 +8,7 @@
/* Output is ca65 6502 assembler for including in project */
/* TOOD:
have a VLIN_ADD like there is for HLIN and BOX
have a VLIN_SAME (would save enough bytes. enough to matter?)
some way of detecting smaller foreground objects and drawing them
separately. Tricky to do
sort PLOT in with HLIN so can use HLIN_ADD but only where appropriate
@ -783,16 +783,16 @@ int generate_frame(int print_results) {
case ACTION_VLIN:
if (primitive_list[i].type==previous_primitive) {
if (print_results) printf("\t.byte %d,%d,%d\n",
primitive_list[i].x1,
primitive_list[i].y1,
primitive_list[i].y2,
primitive_list[i].x1);
primitive_list[i].y2);
total_size+=3;
}
else {
if (print_results) printf("\t.byte VLIN,%d,%d,%d\n",
primitive_list[i].x1,
primitive_list[i].y1,
primitive_list[i].y2,
primitive_list[i].x1);
primitive_list[i].y2);
total_size+=4;
previous_primitive=ACTION_VLIN;

View File

@ -0,0 +1,5 @@
#!/bin/sh
for i in `seq -w 15 130` ; do
./box_convert ./modified/image00000$i.png> frame$i.inc ;
done

View File

@ -104,11 +104,10 @@ update_pointer_already_in_a:
bcc draw_scene_loop ; bra (would only be set if wrap $FFFF)
;============================
; done scene
;============================
; increment pointer and return
; return
done_scene:
rts
@ -143,8 +142,6 @@ bytes_used:
.byte 1,3,2,2 ; HLIN_ADD_RSAME, BOX_ADD, BOX_ADD_LSAME
.byte 2,2 ; BOX_ADD_RSAME, VLIN_ADD
draw_table_l:
.byte <(clear_screen),<(draw_box),<(draw_hlin),<(draw_vlin)
.byte <(draw_plot)
@ -165,7 +162,6 @@ draw_table_h:
;=================================
clear_screen:
jmp clear_fullgr ; tail call
; jmp draw_scene_loop ; skip inc pointer
;=================================
;=================================
@ -259,10 +255,6 @@ draw_box_xloop_smc:
bcs draw_box_xloop ; bge
iny
;draw_box_yend_smc:
; cpy #0
; bcc draw_box_yloop ; less than
; beq draw_box_yloop ; equal
jmp draw_box_yloop
@ -280,8 +272,6 @@ done_draw_box_yloop:
definitely_odd_bottom:
; done
; jmp update_pointer
rts
@ -301,7 +291,6 @@ draw_hlin:
lda (INL),Y
sta Y1 ; needed for HLIN_ADD
; lda Y1
lsr
tay
@ -314,9 +303,6 @@ do_hlin_mask_odd:
; done
hlin_done:
rts
; jmp update_pointer
;=================================
;=================================
@ -333,10 +319,8 @@ draw_hlin_add:
sta X2
inc Y1
lda Y1
; sta Y1
; lda Y1
lda Y1
lsr
tay
@ -348,7 +332,6 @@ do_hlin_add_mask_odd:
; done
hlin_add_done:
; jmp update_pointer
rts
;=================================
@ -366,9 +349,6 @@ draw_hlin_add_lsame:
inc Y1
lda Y1
; sta Y1
; lda Y1
lsr
tay
bcs do_hlin_add_lsame_mask_odd
@ -379,7 +359,6 @@ do_hlin_add_lsame_mask_odd:
; done
hlin_add_lsame_done:
; jmp update_pointer
rts
@ -398,9 +377,6 @@ draw_hlin_add_rsame:
inc Y1
lda Y1
; sta Y1
; lda Y1
lsr
tay
bcs do_hlin_add_rsame_mask_odd
@ -411,7 +387,52 @@ do_hlin_add_rsame_mask_odd:
; done
hlin_add_rsame_done:
; jmp update_pointer
rts
;===================================
;===================================
; hlin common code
;===================================
;===================================
; X1, X2 set up
; Y/2 is in Y
; call the proper entry point
; Y untouched
hlin_common:
hlin_mask_odd:
lda #$0F
.byte $2C ; bit trick
hlin_mask_even:
lda #$F0
sta MASK
eor #$FF
and COLOR
sta COLOR2
lda gr_offsets_l,Y
sta draw_hlin_l_xloop_smc+1
sta draw_hlin_s_xloop_smc+1
lda gr_offsets_h,Y
clc
adc DRAW_PAGE
sta draw_hlin_l_xloop_smc+2
sta draw_hlin_s_xloop_smc+2
ldx X2
draw_hlin_xloop:
draw_hlin_l_xloop_smc:
lda $400,X
and MASK
ora COLOR2
draw_hlin_s_xloop_smc:
sta $400,X
dex
cpx X1
bpl draw_hlin_xloop ; bge
rts
;=================================
@ -487,18 +508,10 @@ draw_box_add_rsame:
;=================================
;=================================
draw_vlin_add:
lda (INL),Y
sta Y1
iny
lda (INL),Y
sta Y2
inc X1 ; X1 is prev_X1+1
inc X1
bne draw_vlin_skip_x1 ; bra
jsr draw_vlin_common
; jmp update_pointer
rts
;=================================
;=================================
@ -506,19 +519,15 @@ draw_vlin_add:
;=================================
;=================================
draw_vlin:
; iny
lda (INL),Y
sta X1
iny
draw_vlin_skip_x1:
lda (INL),Y
sta Y1
iny
lda (INL),Y
sta Y2
iny
lda (INL),Y
sta X1
jsr draw_vlin_common
; jmp update_pointer
rts
;================================
draw_vlin_common:
@ -535,17 +544,20 @@ odd_bottom_vlin:
sta vlin_yend_smc+1
; handle top
; see if we start at multiple of two
lda Y1
lsr
tay
tay ; needed! Sets Y for vlin_yloop
bcc even_vlin_start
odd_vlin_start:
; we're odd, need to call PLOT
lda Y1
jsr plot_common
jsr plot_mask_odd
iny
iny ; update Y for vlin_yloop
even_vlin_start:
@ -574,10 +586,6 @@ vlin_xloop_smc:
sta $400,X
iny
;vlin_yend_smc:
; cpy #0
; bcc vlin_yloop ; less than
; beq vlin_yloop ; equal
jmp vlin_yloop
@ -590,7 +598,8 @@ done_vlin_yloop:
lsr
bcs definitely_odd_vlin
jsr plot_mask_even
lda Y2
jmp plot_common ; plot_mask_even (tail call)
definitely_odd_vlin:
; done
@ -606,88 +615,30 @@ definitely_odd_vlin:
;=================================
;=================================
draw_plot:
; iny
lda (INL),Y
sta X1
iny
lda (INL),Y
sta Y1 ; needed for HLIN_ADD
; lda Y1
lsr
tay
bcs do_plot_mask_odd
jsr plot_mask_even
jmp plot_done
do_plot_mask_odd:
jsr plot_mask_odd
; fallthrough
plot_done:
; done
; jmp update_pointer
rts
;===================================
;===================================
; hlin common code
;===================================
;===================================
; X1, X2 set up
; Y/2 is in Y
; call the proper entry point
; Y untouched
hlin_common:
hlin_mask_odd:
lda #$0F
.byte $2C ; bit trick
hlin_mask_even:
lda #$F0
sta MASK
eor #$FF
and COLOR
sta COLOR2
lda gr_offsets_l,Y
sta draw_hlin_l_xloop_smc+1
sta draw_hlin_s_xloop_smc+1
lda gr_offsets_h,Y
clc
adc DRAW_PAGE
sta draw_hlin_l_xloop_smc+2
sta draw_hlin_s_xloop_smc+2
ldx X2
draw_hlin_xloop:
draw_hlin_l_xloop_smc:
lda $400,X
and MASK
ora COLOR2
draw_hlin_s_xloop_smc:
sta $400,X
dex
cpx X1
bpl draw_hlin_xloop ; bge
rts
;===================================
;===================================
; plot common code
;===================================
;===================================
; X1, set up
; Y/2 is in Y
; call the proper entry point
; Y untouched
; X-coord in X1
; Y-coord in A
; Y is Y-coord/2 at end
plot_common:
lsr ; need Y-coord/2 because 2 rows per byte
tay
bcc plot_mask_even
plot_mask_odd:
lda #$0F
.byte $2C ; bit trick