;------------------------------------------------------------------------
;
;		Copyright 2012 Intergraded Logic Systems
;                  Source Code is Copyright Stephen J. Carden
;
;
;			Please do not share this source!
;------------------------------------------------------------------------
;        title   'Drive programming Stuff'
;------------------------------------------------------------------------
;                              make_bad.s
;With the super achiver with bit writer
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;------------------------------------------------------------------------
;                         Real.dos Make_bad
;
;
;	Code History.     Init design,   7/5/2012	sjc
;
;
;
;       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;------------------------------------------------------------------------
; Notes: o This source code MAY NOT be placed for download on any BBS's!
;        o "mea" is a macro that loads the address of the first field
;          into the pointer specified by the second field.
;------------------------------------------------------------------------
; Assembler:  MADMAC (tm) ST Cross Assembler (Atari Corp)
;             XASM   st and IBM VERSIONS
;------------------------------------------------------------------------

com_file_name:		.macro
;			dc.b   13,"filename.ext",$9b
			dc.b   12,"Make_bad.com",$9b
			.endm

;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; File revision history. Version Number in hex
;
file_ver:		equ   $10
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the Month in dec for the first time this revision 
;was compiled
;
c_month:		equ   10
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the day in dec for the first time this revision 
;was compiled
c_day:			equ   16
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; the year in dec for the first time this revision 
;was compiled
c_year:			equ   2012
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Type of compiler used in program
;
; 0 = unknown Compiler
; 1 = xasm
; 2 = mac_65
; 3 = basic
; 4 = compiled basic xl
; 5 = C65
; 6 = Action
;
; We can add more as time goes on!
;
;
xasm:			equ	1
mac_65:			equ	2 
basic:			equ	3
basicxl:		equ	4
c65:			equ	5
action:			equ	6

file_compiler:		equ	xasm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; is this relocatable code ?
; anyother value other than 1 or 2 would be unknown
r..yes:			equ	1
r..no:			equ	2
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define if it can be relocated
l_relocatable:		equ	r..no
;
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Gotta define if it can be relocated
r..crl:			equ	$7d
r..crlf:		equ	$9b
r..space:		equ	$20

l_frstscreenbyte:	equ	r..crl
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; The language the output file is in. 
;
;
; 0	=	Undifined
; 1	=	English
; 2	=	German
;
r..language:		equ	1
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




d_sector:	equ	365
b_code:		equ	fi_sector+1
start_fuzz:	equ	64
end_fuzz:	equ	127
;
;
;


		.include	equates
		.include	globals
		.include	macros


		.org	$5000


;
;
win_start:
header_info:

		.include	header			; this reads info out of the header and displays to screen

		jmp	top
;----------------------------------
;printsi Routeen macro             
;this is a slow print to the screen
;----------------------------------
;
sprintsi: pla
         sta $b0
         pla
         sta $b1
         ldy #$01
e8894:    lda ($b0),y
         cmp #$ff
         beq m88a1
         jsr sprint
         jsr l88ab
         jmp e8894
m88a1:    jsr l88ab
         lda $b1
         pha
         lda $b0
         pha
         rts
l88ab:    inc $b0
         bne l88b1
         inc $b1
l88b1:    rts
;
;
;------------;
; PRINT BYTE 
;------------;
echo:
sprint:   sta $b8
         lda #$04
         sta $034a
         stx $b6
         sty $b7
         ldx #$06
         lda $e400+1,x
         sta $b3
         lda $e400,x
         sta $b2
         lda $b8
         jsr l88da
         ldx $b6
         ldy $b7
         lda #$0c
         sta $034a
         lda $b8
         rts
;
l88da:    inc $b2
         jmp ($b2)
         rts
;------------------------------;
;   GET KEY  ROUTEEN           ;
;this routeen get's one key and;
;return it to the accumlator   ;
;------------------------------;
;
getkey:   stx $b6
         sty $b7
         jsr g_fff
         ldx $b6
         ldy $b7
         rts
g_fff:    lda $e420+5
         pha
         lda $e420+4
         pha
         rts
;
;-----------------------------;
;CHANGES THE CHARTER TO UPCASE;
;-----------------------------;
upcase:
         cmp #$61
         bcc upcase_exit
         cmp #$7a
         bcs upcase_exit
         sbc #$1f
upcase_exit: rts
;
;-----------------------------;
;CHANGES THE CHARTER TO LOCASE;
;-----------------------------;
locase:
         cmp #$41
         bcc locase_exit
         cmp #$5a
         bcs locase_exit
         adc #$1f
locase_exit: rts
;
;----------------------------------;
;    ERROR NUMBER                  ;
;this take's the value of the a reg;
;and put a hex number to the screen;
;----------------------------------;
;
h_cardd:  dc.b $00
;
; print a hex word value
; low byte in a reg x is high byte
;
h_card:   sta h_cardd
         txa
         jsr drive_error
         lda h_cardd
         jsr drive_error
         rts
;
;
drive_error: pha
         lsr
         lsr
         lsr
         lsr
         jsr l8913
         pla
         and #$0f
l8913:    cmp #$0a
         bcs l891b
         ora #$30
         bne l891d
l891b:    adc #$36
l891d:    jsr sprint
         rts
;
;
;----------------------------;
;   jsr  printsi             ;
;this prints an inline string;
;     terminated by $ff      ;
;----------------------------;
;        jsr   prints
;       .BYTE "print this",$9B,$FF
echosi:
printsi:  pla
         sta pstr+1
         pla
         sta pstr+2
prsl:     inc pstr+1
         bne pstr
         inc pstr+2
pstr:     lda $ffff
         cmp #$ff
         beq estri
         jsr fast_output
         jmp prsl
estri:    lda pstr+2
         pha
         lda pstr+1
         pha
         rts
;
;-------------------------;
;actual screen handler    ;
;screen offset definitions;
;-------------------------;
scr_offset: dc.w 0
         dc.w 40
         dc.w 80
         dc.w 120
         dc.w 160
         dc.w 200
         dc.w 240
         dc.w 280
         dc.w 320
         dc.w 360
         dc.w 400
         dc.w 440
         dc.w 480
         dc.w 520
         dc.w 560
         dc.w 600
         dc.w 640
         dc.w 680
         dc.w 720
         dc.w 760
         dc.w 800
         dc.w 840
         dc.w 880
         dc.w 920
;
fast_output: sta $5a
         cmp #32
         bcc do_look
         cmp #125
         bcc do_here
do_look:  ldy #0
lookup:   lda char_table,y
         beq do_here
         cmp $5a
         beq go_cio
         iny
         bne lookup
go_cio:   lda $5a
         jmp putlocal
do_here:  ldy #0
         lda $5d
         sta ($5e),y
         lda $5a
         cmp #$9b
         beq docr
notcr:    jsr get_adr
         lda $5a
         and #$7f
         cmp #32
         bcc add64
         cmp #96
         bcc sub32
         jmp asis
add64:    clc
         adc #64
         jmp asis
sub32:    sec
         sbc #32
asis:     bit $5a
         bpl xxlate
         ora #$80
xxlate:   ldy #0
         sta ($5e),y
         inc $55
         inc $63
         lda $55
         cmp #40
         bcs next_row
         iny
         lda ($5e),y
         sta $5d
         ora #$80
         ldx 752
         bne nocurs1
         sta ($5e),y
nocurs1:  inc $5e
         bne nooav
         inc $5e+1
nooav:    rts
docr:     lda #0
         sta $63
next_row: lda $52
         sta $55
         inc $54
         ldy $54
         cpy #24
         bcs scroll
         jsr get_adr
         ldy #0
         lda ($5e),y
         sta $5d
         ldx 752
         bne nocurs2
         ora #$80
         sta ($5e),y
nocurs2:  rts
scroll:   dec $54
         lda $58
         sta $68
         clc
         adc #40
         sta $5e
         lda $58+1
         sta $68+1
         adc #0
         sta $5e+1
         ldy #0
         ldx #3
scloop:   lda ($5e),y
         sta ($68),y
         iny
         bne scloop
         inc $5e+1
         inc $68+1
         dex
         bne scloop
scloop2:  lda ($5e),y
         sta ($68),y
         iny
         cpy #152
         bcc scloop2
         lda $58
         clc
         adc #920&$ff
         sta $5e
         lda $58+1
         adc #920/256
         sta $5e+1
         ldy #0
         tya
clear:    sta ($5e),y
         iny
         cpy #40
         bcc clear
         ldx 752
         bne nocurs3
         lda #$80
         ldy $55
         sta ($5e),y
nocurs3:  lda #0
         sta $5d
         lda $5e
         clc
         adc $55
         sta $5e
         lda $5e+1
         adc #0
         sta $5e+1
         rts
get_adr:  lda $54
         asl
         tay
         lda $58
         clc
         adc scr_offset,y
         sta $5e
         lda $58+1
         adc scr_offset+1,y
         sta $5e+1
         lda $5e
         clc
         adc $55
         sta $5e
         lda $5e+1
         adc #0
         sta $5e+1
         rts
char_table:
         dc.b 27,28,29,30,31,125,126,127
         dc.b 156,157,158,159,253,254,255,0
putlocal: ldx #11
         stx $0342
         ldx #0
         stx $0348
         stx $0349
         jmp $e456
;
;
;----------------------------------;
;THIS ROUTEEN WILL PAUSE 1 SEC.    ;
;        PAUSE JIFFIY              ;
;USES LOAD THE A REGISTER JSR PAUSE;
;----------------------------------;
;
pause:
         sta pause_data
         lda #$00
         sta pause_data+2
p_l1:     lda #$00
         sta $14
         clc
pause_loop:
         lda $14
         cmp pause_data+1
         bcc pause_loop
         inc pause_data+2
         lda pause_data+2
         cmp pause_data
         bcc p_l1
         rts
pause_data: dc.b $00,60,$00
;--------------------
;     JIFFIY PAUSE   
;--------------------
;
jiffiy:   sta jiy_h
         clc
         lda #$00
         sta $14
jif_loop: lda $14
         cmp jiy_h
         bcc jif_loop
         rts
jiy_h:    dc.b 0
;

;
;-------------------------------
;        JSR ECHOS              
;LOAD THE LOW BYTE INTO fi_pr_ptr   
;LOAD THE HIGH BYTE INTO fi_pr_ptr+1
;JSR ECHOS.BYTE $00,"NAME"      
;-------------------------------
;
prints:
echos:
         pha
         pha
         clc
         lda fi_pr_ptr
         sta e_print+1
         sta a_print+1
         lda fi_pr_ptr+1
         sta e_print+2
         sta a_print+2
         lda #$00
         sta fi_pr_ptr+2
w_print:  ldy fi_pr_ptr+2
         iny
         sty fi_pr_ptr+2
e_print:  lda $ffff,y
         jsr sprint
         ldy fi_pr_ptr+2
a_print:  cpy $ffff
         bcc w_print
         pla
         pla
         rts
fi_pr_ptr:    dc.b 0,0,0
;
;
;-------------------------------
;       JSR GETSTRING           
;LOAD THE LOW BYTE INTO fi_s_ptr    
;THE HIGH BYTE INTO fi_s_ptr+1      
;LOAD THE MAX LENGHT INTO Y REG.
;-------------------------------
;
;
getstring:
         lda #$9b
         sta x1_get+1
         sty x_get+1
         cpx #$ff
         bne wq_get
         stx x1_get+1
wq_get:   lda fi_s_ptr
         sta g_get+1
         sta b_get+1
         sta s_get+1
         sta w_get+1
         sta t_get+1
         sta back_s+1
         lda fi_s_ptr+1
         sta g_get+2
         sta b_get+2
         sta s_get+2
         sta w_get+2
         sta t_get+2
         sta back_s+2
         ldy #$01
get_loop: clc
         jsr getkey
         cmp #$1c    ; CURSER UP
         bcc g_get
         cmp #$20
         bcc get_loop
g_get:    sta $ffff,y
x1_get:   cmp #$9b
         beq g_exit
         cmp #$7e
         beq back_s
s_get:    inc $ffff
         jsr sprint
         iny
x_get:    cpy #$ff
         beq g_exit
         bne get_loop
g_exit:   jsr sprint
t_get:    inc $ffff
         rts
back_s:   lda $ffff
         cmp #$00
         beq get_loop
b_get:    dec $ffff
w_get:    lda $ffff
         cmp #$00
         bcc get_loop
         tya
         dey
         lda #$7e
         jsr sprint
         cmp #$00
         bne get_loop
         beq get_loop


fi_s_ptr:     dc.w 0

fi_d_ptr:     dc.w 0
fi_test_byte: dc.b 0,0,0,0
;
;
;-----------------------------
;COMPARE STRING'S fi_s_ptr TO fi_d_ptr
;-----------------------------
;
cmpstr:   clc
         lda #$01
         sta fi_test_byte+3
         lda fi_s_ptr
         sta c_sptr+1
         sta cmp_word+1
         sta cmp_check1+1
         lda fi_s_ptr+1
         sta c_sptr+2
         sta cmp_word+2
         sta cmp_check1+2
         lda fi_d_ptr
         sta c_dptr+1
         sta cmp_check2+1
         lda fi_d_ptr+1
         sta c_dptr+2
         sta cmp_check2+2
cmp_check1: lda $ffff
cmp_check2: cmp $ffff
         bne w_cmpstr
cmp_word: lda $ffff
         sta fi_test_byte+2
         ldy #$00
cmp_loop: iny
         clc
         cpy fi_test_byte+2
         beq cmp_exit
         clc
c_sptr:   lda $ffff,y
         jsr locase
         sta fi_test_byte
c_dptr:   lda $ffff,y
         jsr locase
         cmp fi_test_byte
         bne w_cmpstr
         beq cmp_loop
w_cmpstr:
         lda #$00
         sta fi_test_byte+3
cmp_exit: lda fi_test_byte+3
         cmp #$01
         rts
;
;
;--------------------------------
; LENGHT TO 0 BYTE STRING        
; SRC STRING fi_s_ptr DES STRING fi_d_ptr
;--------------------------------
;
toascii:
         lda fi_s_ptr
         sta src_asc+1
         sta src_hold+1
         lda fi_s_ptr+1
         sta src_asc+2
         sta src_hold+2
         lda fi_d_ptr
         sta des_hold+1
         sta src_e+1
         lda fi_d_ptr+1
         sta des_hold+2
         sta src_e+2
         ldy #$01
         ldx #$00
src_hold: lda $ffff,y
des_hold: sta $ffff,x
         iny
         inx
src_asc:  cpy $ffff
         beq src_exit
         bne src_hold
src_exit: lda #$00
src_e:    sta $ffff,x
         rts
;
;-------------------
; 0 TO LENGHT STRING
;-------------------
tostr:
         lda fi_s_ptr
         sta tostr_sr+1
         lda fi_s_ptr+1
         sta tostr_sr+2
         lda fi_d_ptr
         sta tostr_dr+1
         sta tostr_hold+1
         sta tostr_ho+1
         lda fi_d_ptr+1
         sta tostr_dr+2
         sta tostr_hold+2
         sta tostr_ho+2
         ldy #$00
tostr_ho: sty $ffff
         ldx #$01
tostr_sr: lda $ffff,y
         cmp #$00
         beq tostr_exit
tostr_dr: sta $ffff,x
         iny
         inx
tostr_hold: inc $ffff
         beq tostr_sr
         bne tostr_sr
tostr_exit:
         rts
;
;
;-------------------
; JSR CONCAT APPENDS
; SPRT TO fi_d_ptr      
;-------------------
;
concat:
         lda fi_s_ptr
         sta con_s+1
         sta con_hold+1
         lda fi_s_ptr+1
         sta con_s+2
         sta con_hold+2
         lda fi_d_ptr
         sta con_d+1
         sta con_de+1
         sta con_dd+1
         lda fi_d_ptr+1
         sta con_d+2
         sta con_de+2
         sta con_dd+2
con_de:   ldy $ffff
         iny
         ldx #$01
con_s:    lda $ffff,x
con_d:    sta $ffff,y
con_dd:   inc $ffff
         iny
         inx
con_hold: cpx $ffff
         bmi con_s
         rts
;
;
;------------
; JSR MOVESTR
;------------
movestr:
         lda fi_s_ptr
         sta mov_s+1
         sta mov_h+1
         lda fi_s_ptr+1
         sta mov_s+2
         sta mov_h+2
         lda fi_d_ptr
         sta mov_d+1
         lda fi_d_ptr+1
         sta mov_d+2
mov_h:    ldy $ffff
mov_s:    lda $ffff,y
mov_d:    sta $ffff,y
         cpy #$00
         beq mov_ew
         dey
         bne mov_s
         beq mov_s
mov_ew:   rts
;------------------------
;JSR GETCARD
;
;------------------------
gtbyte:   dc.b $00,"       "
qstrin:   dc.b "       "
gtwr:     dc.b $03,$06
getbyte:
         lda gtwr
         sta gt1+1
         ldy #$00
         sty gtbyte
         cmp gtwr
         beq gt1
getcard:
         lda gtwr+1
         sta gt1+1
         ldy #$00
         sty gtbyte
gt1:      cpy #$ff
         beq gt3
         jsr getkey
         jsr upcase
         cmp #$9b
         beq gt3
         cmp #$7e    ; BACKSPACE
         beq gt2
	 cmp #'0'
         bcc gt1
	 cmp #':'
         bpl gt1
         ldy gtbyte
         iny
         sty gtbyte
         sta gtbyte,y
         jsr echo
         cmp #$ff
         bne gt1
         beq gt1
gt2:      ldy gtbyte  ; BACKSPACE
         cpy #$00
         beq gt1
         lda #$7e
         jsr echo
         dec gtbyte
         cmp #$ff
         bne gt1
         beq gt1
;
;-MATH SHIT FOR CARD CONVERSION-
gt3:
         lda #$9b
         ldy gtbyte
         iny
         sta gtbyte,y
         sty gtbyte
         lda # low gtbyte
         sta fi_s_ptr
         lda # high gtbyte
         sta fi_s_ptr+1
         lda # low qstrin
         sta fi_d_ptr
         lda # high qstrin
         sta fi_d_ptr+1
         jsr toascii
         lda # low qstrin
         sta $f3
         lda # high qstrin
         sta $f3+1
         lda #$00
         sta $f2
         jsr $d800
         jsr $d9d2
         lda $d4
         ldx $d4+1
         rts


pr_byte:
         ldx #$00
pr_card:
         sta $d4
         stx $d4+1
         lda #$00
         sta $f2
         jsr $d9aa
         jsr $d8e6
         ldy #$00
.aprbloop:
         lda ($f3),y
         php
         and #$7f
         iny
         jsr echo
         plp
         bpl .aprbloop
         rts
;
;
start:    dc.w $016d
stop:     dc.w $0410
;
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;the code to really makes things Work with the Archiver and bit writter
;
;
;
load_block:
		ldy #$01
		lda d_num
         sta (pr_ptr),y
         ldy #$00
load_block1:
         lda (pr_ptr),y
         sta $0300,y
         iny
         cpy #$0c
         bne load_block1
         rts
;
d_num:    dc.b 0
;
super_archiver:
         dc.b $31,2,115,0,0,0,0,0,0,0,2,0
;
open_chip:
;   .BYTE $31,2,$4F,0,0,0,0,0,0,0,$CD,$AB
         dc.b $31,2,$75,$80
         dc.w megabytes
         dc.w $0b
         dc.b 0
         dc.b 1
         dc.w $2c
;
;
;
megabytes:
;
         dc.b $a0,$2c,$b9,$2b,$10,$99,$a5,$f4
         dc.b $88,$10,$f7,$a0,$08,$b9,$57,$10
         dc.b $99,$ea,$32,$88,$10,$f7,$a0,$27
         dc.b $b9,$63,$10,$99,$33,$33,$88,$10
         dc.b $f7,$a5,$95,$09,$80,$29,$fe,$85
         dc.b $95,$18,$60,$ad,$c5,$f4,$a5,$95
         dc.b $10,$22,$a5,$91,$0a,$66,$98,$0a
         dc.b $26,$97,$0a,$26,$97,$0a,$66,$99
         dc.b $a5,$91,$29,$07,$85,$91,$a0,$02
         dc.b $d0,$02,$00,$02,$a5,$97,$f0,$04
         dc.b $a9,$01,$85,$97,$84,$9a,$60,$ad
         dc.b $00,$10,$49,$ff,$24,$94,$30,$36
         dc.b $8d,$80,$02,$8d,$03,$04,$bd,$01
         dc.b $10,$49,$ff,$ec,$7e,$10,$f0,$10
         dc.b $e8,$e4,$86,$90,$e7,$ad,$80,$02
         dc.b $09,$04,$8d,$80,$02,$4c,$0b,$f3
         dc.b $ad,$80,$02,$49,$04,$8d,$80,$02
         dc.b $18,$90,$e5,$83,$09,$45,$00,$80
         dc.b $00,$00,$80
;
;
;
kill_sector:
		dc.b	$31   ;$300
		dc.b	2     ;$301
		dc.b	"q"   ;$302
		dc.b	$80   ;$303
		dc.w	message ;$304
		dc.b	$0f   ;$306
		dc.b	0     ;$307
		dc.w	128   ;$308 256 for dd
fi_sector:	dc.w	d_sector ;$30A
		dc.b	0     ;$30C
		dc.b	0     ;$30D
		dc.b	0     ;$30E
		dc.b	0     ;$30F
;
message:
		dc.b	"This is "
		dc.b	"a test o"
		dc.b	"f the ba"
		dc.b	"d writte"
		dc.b	"r progra"
		dc.b	"m. By St"
		dc.b	"ephen J."
		dc.b	" Carden "
;
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0,0,0
		dc.b	0,0,0,0,0,0
		dc.b	start_fuzz
		dc.b	end_fuzz
;
top:
		jsr	printsi
		dc.b	$9b," This Program is for a Super Archiver"
		dc.b	$9b,"        With a bit Writter"
		dc.b	$9b," Fuzz's the sector of your choice!"
		dc.b	$9b,$9b,$9b,$9b
		dc.b	" What drive ",$FF
		jsr	getbyte
		sta	d_num
;
back_trak:
;
         lda start
         sta fi_sector
         lda start+1
         sta fi_sector+1
         jsr printsi
         dc.b $9b," Insert Destionation Disk",$9B,$FF
         jsr getkey
          mea  super_archiver,pr_ptr
         jsr load_block
         jsr $e459
         lda $0303
         cmp #$01
         beq top_1
         jmp top
;
top_1:
          mea  open_chip,pr_ptr
         jsr load_block
         jsr $e459
         jsr printsi
         dc.b "  ",$FF
         lda $0303
         jsr pr_byte
kill_next:
         jsr add_one
          mea  kill_sector,pr_ptr
         jsr load_block
         lda b_code
         eor #$80
         sta $030b
         jsr $e459
         tya
         pha
         jsr printsi
         dc.b $9b,"    ",$FF
         lda fi_sector
         ldx fi_sector+1
         jsr pr_card
;
         jsr printsi
         dc.b " Sector Killed ",$FF
         pla
         jsr pr_byte
         jsr check_end
         cmp #$00
         beq A22
         jmp kill_next
;
A22:
         jsr printsi
         dc.b $9b,$9b
         dc.b " DO IT AGAIN? [y,N]?",$FF
         jsr getkey
         jsr upcase
         cmp #'Y'
         bne A11
         jmp back_trak
A11:
         rts
;
add_one:
         inc fi_sector
         lda fi_sector
         cmp #$00
         bne add_one1
         inc fi_sector+1
add_one1:
         rts
;
;
check_end:
         lda fi_sector+1
         cmp stop+1  ;   #$04
         bne check_end1
         lda fi_sector
         cmp stop    ;  #$10
         bne check_end1
         lda #$00
         rts
check_end1:
         lda #$01
         rts
;
win_end:	ds.b	0
;