mirror of
https://github.com/deater/dos33fsprogs.git
synced 2024-09-29 08:55:10 +00:00
second: more messing with draw_boxes
This commit is contained in:
parent
3251444dd5
commit
07377a0204
@ -1,29 +1,23 @@
|
|||||||
;
|
;==========================
|
||||||
;
|
; draw box scene
|
||||||
; optional color, x1,y1 x2,y2
|
;==========================
|
||||||
;
|
|
||||||
; HLIN x1,x2 at y1
|
|
||||||
; VLIN y1,y2 at X1
|
|
||||||
; PLOT x1,y1
|
|
||||||
; BOX x1,y1 to x2,y2
|
|
||||||
; CLEAR -
|
|
||||||
|
|
||||||
; data in INL/INH
|
; data in INL/INH
|
||||||
|
|
||||||
SET_COLOR = $C0
|
SET_COLOR = $C0 ; special case, color 0..15 in bottom nybble
|
||||||
END = $80
|
|
||||||
CLEAR = $81
|
END = $80 ; 0 :
|
||||||
BOX = $82
|
CLEAR = $81 ; 0 : clear screen to black (0)
|
||||||
HLIN = $83
|
BOX = $82 ; 4 : x1,y1 to x2,y2
|
||||||
VLIN = $84
|
HLIN = $83 ; 3 : x1,x2 at y1
|
||||||
PLOT = $85
|
VLIN = $84 ; 3 : y1,y2 at x1
|
||||||
HLIN_ADD= $86
|
PLOT = $85 ; 2 : x1,y1
|
||||||
HLIN_ADD_LSAME= $87
|
HLIN_ADD= $86 ; 2 : x1,x2 at prev_y1+1
|
||||||
HLIN_ADD_RSAME= $88
|
HLIN_ADD_LSAME= $87 ; 1 : prev_x1,x2 at prev_y1+1
|
||||||
BOX_ADD= $89
|
HLIN_ADD_RSAME= $88 ; 1 : x1,prev_x2 at prev_y1+1
|
||||||
BOX_ADD_LSAME= $8A
|
BOX_ADD= $89 ; 3 : x1,prev_y1+1, x2, y2
|
||||||
BOX_ADD_RSAME= $8B
|
BOX_ADD_LSAME= $8A ; 2 : prev_x1,prev_y1+1, x2, y2
|
||||||
VLIN_ADD= $8C
|
BOX_ADD_RSAME= $8B ; 2 : x1,prev_y1+1, prev_x2, y2
|
||||||
|
VLIN_ADD= $8C ; 2 : y1,y2 at prev_x1+1
|
||||||
|
|
||||||
BLACK = $00
|
BLACK = $00
|
||||||
RED = $01
|
RED = $01
|
||||||
@ -46,12 +40,13 @@ WHITE = $0f
|
|||||||
; top bit set, repeat last command
|
; top bit set, repeat last command
|
||||||
|
|
||||||
|
|
||||||
; 11xx xxxx
|
; ??xx xxxx
|
||||||
|
|
||||||
; 00 = co-ord
|
; 00 = co-ord
|
||||||
; 10 = new command
|
; 10 = new command
|
||||||
; 11 = new-color
|
; 11 = new-color
|
||||||
|
|
||||||
|
|
||||||
draw_scene:
|
draw_scene:
|
||||||
|
|
||||||
lda #0 ; always clear to black
|
lda #0 ; always clear to black
|
||||||
@ -66,36 +61,63 @@ draw_scene_loop:
|
|||||||
; command
|
; command
|
||||||
|
|
||||||
asl ; clear top bit
|
asl ; clear top bit
|
||||||
beq done_scene ; if 0, END
|
|
||||||
bmi set_color ; if negative, color
|
bmi set_color ; if negative, color
|
||||||
lsr ; shift back down
|
lsr ; shift back down
|
||||||
|
|
||||||
sta LAST_TYPE ; store last type
|
sta LAST_TYPE ; store last type
|
||||||
|
|
||||||
jsr inc_inl
|
jsr inc_inl ; 16 bit increment
|
||||||
|
|
||||||
repeat_last:
|
repeat_last:
|
||||||
lda LAST_TYPE
|
lda LAST_TYPE
|
||||||
|
|
||||||
; iny ; point to next byte
|
beq done_scene ; if 0, END
|
||||||
|
|
||||||
|
|
||||||
; use jump table for rest
|
; use jump table for rest
|
||||||
and #$3f
|
and #$3f
|
||||||
tax
|
tax
|
||||||
dex ; types start at 1
|
dex ; types start at 1
|
||||||
lda draw_table_h,X
|
lda draw_table_h,X
|
||||||
pha
|
sta table_jsr_smc+2
|
||||||
|
; pha
|
||||||
lda draw_table_l,X
|
lda draw_table_l,X
|
||||||
pha
|
; pha
|
||||||
rts ; jump to it
|
sta table_jsr_smc+1
|
||||||
|
|
||||||
|
table_jsr_smc:
|
||||||
|
jsr $FFFF
|
||||||
|
|
||||||
|
;========================================
|
||||||
|
; adds A to input pointer and continues
|
||||||
|
update_pointer:
|
||||||
|
ldx LAST_TYPE
|
||||||
|
lda bytes_used,X
|
||||||
|
|
||||||
|
update_pointer_already_in_a:
|
||||||
|
clc
|
||||||
|
adc INL
|
||||||
|
sta INL
|
||||||
|
lda #0
|
||||||
|
adc INH
|
||||||
|
sta INH
|
||||||
|
bcc draw_scene_loop ; bra (would only be set if wrap $FFFF)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; done scene
|
||||||
|
;============================
|
||||||
|
; increment pointer and return
|
||||||
done_scene:
|
done_scene:
|
||||||
inc INL
|
|
||||||
bne really_done_scene
|
|
||||||
inc INH
|
|
||||||
really_done_scene:
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;============================
|
||||||
|
; set color
|
||||||
|
;============================
|
||||||
|
; color is A*2h
|
||||||
|
|
||||||
set_color:
|
set_color:
|
||||||
; make top and bottom byte the same
|
; make top and bottom byte the same
|
||||||
|
|
||||||
@ -109,34 +131,32 @@ set_color:
|
|||||||
adc COLOR
|
adc COLOR
|
||||||
sta COLOR
|
sta COLOR
|
||||||
|
|
||||||
lda #1 ; we were one byte long
|
; special case as we are encoded differently from
|
||||||
; bne update_pointer
|
; the actions
|
||||||
|
|
||||||
|
lda #1 ; we were one byte long
|
||||||
|
bne update_pointer_already_in_a ; bra
|
||||||
|
|
||||||
; adds A to input pointer and continues
|
bytes_used:
|
||||||
update_pointer:
|
.byte 0,0,4,3 ; END, CLEAR, BOX, HLIN
|
||||||
clc
|
.byte 3,2,2,1 ; VLIN, PLOT, HLIN_ADD, HLIN_ADD_LSAME
|
||||||
adc INL
|
.byte 1,3,2,2 ; HLIN_ADD_RSAME, BOX_ADD, BOX_ADD_LSAME
|
||||||
sta INL
|
.byte 2,2 ; BOX_ADD_RSAME, VLIN_ADD
|
||||||
lda #0
|
|
||||||
adc INH
|
|
||||||
sta INH
|
|
||||||
jmp draw_scene_loop
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
draw_table_l:
|
draw_table_l:
|
||||||
.byte <(clear_screen-1),<(draw_box-1),<(draw_hlin-1),<(draw_vlin-1)
|
.byte <(clear_screen),<(draw_box),<(draw_hlin),<(draw_vlin)
|
||||||
.byte <(draw_plot-1)
|
.byte <(draw_plot)
|
||||||
.byte <(draw_hlin_add-1),<(draw_hlin_add_lsame-1),<(draw_hlin_add_rsame-1)
|
.byte <(draw_hlin_add),<(draw_hlin_add_lsame),<(draw_hlin_add_rsame)
|
||||||
.byte <(draw_box_add-1),<(draw_box_add_lsame-1),<(draw_box_add_rsame-1)
|
.byte <(draw_box_add),<(draw_box_add_lsame),<(draw_box_add_rsame)
|
||||||
.byte <(draw_vlin_add-1)
|
.byte <(draw_vlin_add)
|
||||||
draw_table_h:
|
draw_table_h:
|
||||||
.byte >(clear_screen-1),>(draw_box-1),>(draw_hlin-1),>(draw_vlin-1)
|
.byte >(clear_screen),>(draw_box),>(draw_hlin),>(draw_vlin)
|
||||||
.byte >(draw_plot-1)
|
.byte >(draw_plot)
|
||||||
.byte >(draw_hlin_add-1),>(draw_hlin_add_lsame-1),>(draw_hlin_add_rsame-1)
|
.byte >(draw_hlin_add),>(draw_hlin_add_lsame),>(draw_hlin_add_rsame)
|
||||||
.byte >(draw_box_add-1),>(draw_box_add_lsame-1),>(draw_box_add_rsame-1)
|
.byte >(draw_box_add),>(draw_box_add_lsame),>(draw_box_add_rsame)
|
||||||
.byte >(draw_vlin_add-1)
|
.byte >(draw_vlin_add)
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -144,9 +164,8 @@ draw_table_h:
|
|||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
clear_screen:
|
clear_screen:
|
||||||
jsr clear_fullgr
|
jmp clear_fullgr ; tail call
|
||||||
lda #0
|
; jmp draw_scene_loop ; skip inc pointer
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -165,7 +184,6 @@ clear_screen:
|
|||||||
; 3/4 case, 2 to 1 (!)
|
; 3/4 case, 2 to 1 (!)
|
||||||
; 3/6 case, 2 to 2
|
; 3/6 case, 2 to 2
|
||||||
draw_box:
|
draw_box:
|
||||||
; iny
|
|
||||||
lda (INL),Y
|
lda (INL),Y
|
||||||
sta X1
|
sta X1
|
||||||
iny
|
iny
|
||||||
@ -176,13 +194,10 @@ draw_box:
|
|||||||
sta X2
|
sta X2
|
||||||
iny
|
iny
|
||||||
lda (INL),Y
|
lda (INL),Y
|
||||||
sta Y2
|
sta Y2 ; keep even though not necessary
|
||||||
|
|
||||||
jsr draw_box_common
|
|
||||||
|
|
||||||
done_draw_box:
|
; fall through
|
||||||
lda #4
|
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
|
|
||||||
;==================================
|
;==================================
|
||||||
@ -211,7 +226,7 @@ odd_bottom_draw_box:
|
|||||||
|
|
||||||
; we're odd, need to call HLIN
|
; we're odd, need to call HLIN
|
||||||
|
|
||||||
jsr hlin_mask_odd
|
jsr hlin_common
|
||||||
iny
|
iny
|
||||||
|
|
||||||
|
|
||||||
@ -265,8 +280,9 @@ done_draw_box_yloop:
|
|||||||
definitely_odd_bottom:
|
definitely_odd_bottom:
|
||||||
; done
|
; done
|
||||||
|
|
||||||
rts
|
; jmp update_pointer
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
@ -293,12 +309,12 @@ draw_hlin:
|
|||||||
jsr hlin_mask_even
|
jsr hlin_mask_even
|
||||||
jmp hlin_done
|
jmp hlin_done
|
||||||
do_hlin_mask_odd:
|
do_hlin_mask_odd:
|
||||||
jsr hlin_mask_odd
|
jsr hlin_common
|
||||||
|
|
||||||
; done
|
; done
|
||||||
hlin_done:
|
hlin_done:
|
||||||
lda #3
|
rts
|
||||||
jmp update_pointer
|
; jmp update_pointer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -328,13 +344,12 @@ draw_hlin_add:
|
|||||||
jsr hlin_mask_even
|
jsr hlin_mask_even
|
||||||
jmp hlin_add_done
|
jmp hlin_add_done
|
||||||
do_hlin_add_mask_odd:
|
do_hlin_add_mask_odd:
|
||||||
jsr hlin_mask_odd
|
jsr hlin_common
|
||||||
|
|
||||||
; done
|
; done
|
||||||
hlin_add_done:
|
hlin_add_done:
|
||||||
lda #2
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
rts
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -360,13 +375,13 @@ draw_hlin_add_lsame:
|
|||||||
jsr hlin_mask_even
|
jsr hlin_mask_even
|
||||||
jmp hlin_add_lsame_done
|
jmp hlin_add_lsame_done
|
||||||
do_hlin_add_lsame_mask_odd:
|
do_hlin_add_lsame_mask_odd:
|
||||||
jsr hlin_mask_odd
|
jsr hlin_common
|
||||||
|
|
||||||
; done
|
; done
|
||||||
hlin_add_lsame_done:
|
hlin_add_lsame_done:
|
||||||
lda #1
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
|
rts
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -392,13 +407,12 @@ draw_hlin_add_rsame:
|
|||||||
jsr hlin_mask_even
|
jsr hlin_mask_even
|
||||||
jmp hlin_add_rsame_done
|
jmp hlin_add_rsame_done
|
||||||
do_hlin_add_rsame_mask_odd:
|
do_hlin_add_rsame_mask_odd:
|
||||||
jsr hlin_mask_odd
|
jsr hlin_common
|
||||||
|
|
||||||
; done
|
; done
|
||||||
hlin_add_rsame_done:
|
hlin_add_rsame_done:
|
||||||
lda #1
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
rts
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -418,12 +432,9 @@ draw_box_add:
|
|||||||
sta X2
|
sta X2
|
||||||
iny
|
iny
|
||||||
lda (INL),Y
|
lda (INL),Y
|
||||||
sta Y2
|
sta Y2 ; needed?
|
||||||
|
|
||||||
jsr draw_box_common
|
jmp draw_box_common
|
||||||
|
|
||||||
lda #3
|
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
@ -443,12 +454,9 @@ draw_box_add_lsame:
|
|||||||
sta X2
|
sta X2
|
||||||
iny
|
iny
|
||||||
lda (INL),Y
|
lda (INL),Y
|
||||||
sta Y2
|
sta Y2 ; needed?
|
||||||
|
|
||||||
jsr draw_box_common
|
jmp draw_box_common
|
||||||
|
|
||||||
lda #2
|
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
@ -468,12 +476,9 @@ draw_box_add_rsame:
|
|||||||
sta X1
|
sta X1
|
||||||
iny
|
iny
|
||||||
lda (INL),Y
|
lda (INL),Y
|
||||||
sta Y2
|
sta Y2 ; needed?
|
||||||
|
|
||||||
jsr draw_box_common
|
jmp draw_box_common
|
||||||
|
|
||||||
lda #2
|
|
||||||
jmp update_pointer
|
|
||||||
|
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
@ -492,8 +497,8 @@ draw_vlin_add:
|
|||||||
|
|
||||||
jsr draw_vlin_common
|
jsr draw_vlin_common
|
||||||
|
|
||||||
lda #2
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
rts
|
||||||
|
|
||||||
;=================================
|
;=================================
|
||||||
;=================================
|
;=================================
|
||||||
@ -512,9 +517,8 @@ draw_vlin:
|
|||||||
sta X1
|
sta X1
|
||||||
jsr draw_vlin_common
|
jsr draw_vlin_common
|
||||||
|
|
||||||
lda #3
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
rts
|
||||||
|
|
||||||
|
|
||||||
;================================
|
;================================
|
||||||
draw_vlin_common:
|
draw_vlin_common:
|
||||||
@ -625,9 +629,8 @@ plot_done:
|
|||||||
|
|
||||||
; done
|
; done
|
||||||
|
|
||||||
lda #2
|
; jmp update_pointer
|
||||||
jmp update_pointer
|
rts
|
||||||
|
|
||||||
|
|
||||||
;===================================
|
;===================================
|
||||||
;===================================
|
;===================================
|
||||||
@ -639,6 +642,8 @@ plot_done:
|
|||||||
; call the proper entry point
|
; call the proper entry point
|
||||||
; Y untouched
|
; Y untouched
|
||||||
|
|
||||||
|
hlin_common:
|
||||||
|
|
||||||
hlin_mask_odd:
|
hlin_mask_odd:
|
||||||
lda #$0F
|
lda #$0F
|
||||||
.byte $2C ; bit trick
|
.byte $2C ; bit trick
|
||||||
@ -713,7 +718,8 @@ plot_s_smc:
|
|||||||
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
;===========================
|
||||||
|
; 16-bit increment of INL
|
||||||
; inline this?
|
; inline this?
|
||||||
inc_inl:
|
inc_inl:
|
||||||
inc INL
|
inc INL
|
||||||
|
Loading…
Reference in New Issue
Block a user