A86: Re: Hello, I'm new at this


[Prev][Next][Index][Thread]

A86: Re: Hello, I'm new at this




Check this out and lemme know if it helps...
It's kinda a long code...here goes

HAVE FUN!  just use this as a prog to call, don't rewrite it into a prog
ur making.

; Variable transfer routines... takes mem addr to VAT or
; page number to program and does the deed..
get_e2:				;
	call clearmenu		; Clear
	ld hl,$0C00		;
	ld (_penCol),hl		;
	ld hl,vrec		;
	call D_ZM_STR		;
	ld hl,$1500		;
	ld (_penCol),hl		;
	ld hl,onpg		;
	call D_ZM_STR		;
	ld hl,$1B00		;
	ld (_penCol),hl		;
	ld hl,vleft		;
	call D_ZM_STR		;
	ld hl,8			; Get name into buffer1
	ld (numba),hl		;
	ld a,4			;
	ld (pstart),a		;
	ld hl,buffer2		;
	call get_sfe		;
	call get_check		; Does variable already exist?!?	
	jp c,ge2_exists		; Already exists! (Undo extra
push)
	call calc_nl		; Return name length in b
	ld hl,buffer2-1		; Setup for VAT call (overwrite
some of buf1)
	ld (hl),b		;
	dec hl			;
	push hl			;
	ld hl,1			;
	ld (numba),hl		;
	ld a,12			;
	ld (pstart),a		;
	ld hl,temp		;
	call get_sfe		; Get into buffer1 -- Should check
for EIIS
	pop hl			;
	ld a,(temp)		;
	cp $08			; 86 Program
	jr z,gete2_prog		;
	cp $0A			;
	jr z,gete2_stng		; 86 String
	cp $0B			; 86 Picture
	jr z,gete2_pic		;
	ld hl,$302A		;
	ld (_penCol),hl		;
	ld hl,vunkn		;
	jp disp_pause_exit	;

; This will all be different on 85, 83
gete2_prog:
	ld (hl),$12		;
	rst 20h			; Copy into OP1
	call get_e2size		; Get size into HL
	call _CREATEPROG	;
	jr fill_variable	;

gete2_stng:
	ld (hl),$0C		;
	rst 20h			;
	call get_e2size		; Get size into HL:
	call _CREATESTRNG	; Create that puppy
	jr fill_variable	;

gete2_pic:
	ld (hl),$11		;
	rst 20h			; All 86 pictures are same size
	call _CREATEPICT	;

fill_variable:
	ex de,hl		; Put pointer into ahl
	ld a,b			;
	call inc_ahl_word	; Increase pointer 2 over size word!
	call _load_ram_ahl	; Load RAM page with pointer
	ld (datptr),hl		;
	ld a,1			; We have a variable if we're still
here..
	ld (varactive),a	;
	call get_e2size		; Get it again, can optimize later
	ld (size),hl		;
	ld bc,0250		;
	or a
	sbc hl,bc		;
	jr c,get_one_page	; File is under 1 EEPROM page, get one,
exit
	inc hl			;
	ld (size),hl		; We're only getting 249, not 250
	ld a,15			;  
	ld (pstart),a		;
	ld hl,249		;
	ld (numba),hl		;
	ld hl,(datptr)		;
	call get_sfe		; Get with bigass pointer (pain in
ass)
	ld (datptr),hl		;
get_more:			;
	call update_e2var	; Update display
	ld hl,(page)		;
	inc hl			; Move to next page
	ld (page),hl		; 
	ld hl,(size)		;
	ld bc,261		;
	or a			;
	sbc hl,bc		;
	jr c,get_last_page	; Get last page of file
	inc hl			; we're only taking 260 now
	ld (size),hl		;
	ld hl,260		;
	ld (numba),hl		;
	ld a,4			;
	ld (pstart),a		;
	ld hl,(datptr)		;
	call get_sfe		; Get with long pointer
	ld (datptr),hl		;
	jr get_more		; Keep going till done

get_one_page:			;
	ld a,15			;
	ld (pstart),a		;
	jr get_the_page		;
get_last_page:			;
	ld a,4			;
	ld (pstart),a		;
get_the_page:
	ld hl,(size)		;
	ld (numba),hl		;
	ld hl,(datptr)		;
	call get_sfe		; Get the puppy
	xor a			; Successful if we're still here
	ld (varactive),a	;
	ld hl,buffer1		; Clear buffer1
	ld b,9			;
	call _zeromem		;
	ld hl,$302A		;
	ld (_penCol),hl		;
	ld hl,vrecd		;
	jp disp_pause_exit	;

; Calculate name length for VAT calls
calc_nl:
	ld hl,buffer2		;
	ld b,0			;
calc_nl_loop:
	ld a,(hl)		;
	or a			; Count till zero
	ret z			;
	inc hl			;
	inc b			;
	jr calc_nl_loop		;

get_check:
	call _RAM_PAGE_7	; Symbol page
	ld hl,$BFFF		; Start of VAT
check_loop:
	push hl			;
	ld b,9			; Clear buffer2
	ld hl,buffer1		;
	call _zeromem		;
	pop hl			; Restore VAT pointer
	ld bc,-$05		;
	add hl,bc		;
	ld b,(hl)		; Put name length into b
	dec hl			; Move to beginning of name
	ld de,buffer1		; Store in buffer2
	call dnloop		; Copy to buffer1, right way
(backwards VAT)
	push hl			;
	call cmp_buf1_buf2	; Compare to name from E2
	jr c,ret_c		;
	pop hl			; Name length
	ld de,($D298)		; Are we at end of VAT?
	call CP_HL_DE		;
	jp z,no_match		; Nope, its not here
	jr check_loop		; Keep looking for match

ret_c:
	inc sp			;
	inc sp			;
	scf			;
	ret			;

put_e2:				;
	push hl			; VAT addr
	push hl			; Save it a few times
	call clearmenu		;
	ld hl,$0C00		;
	ld (_penCol),hl		;
	ld hl,vsend		;
	call D_ZM_STR
	ld hl,$1500		;
	ld (_penCol),hl		;
	ld hl,onpg		;
	call D_ZM_STR		;
	ld hl,$1B00		;
	ld (_penCol),hl		;
	ld hl,vleft		;
	call D_ZM_STR		;
	call _RAM_PAGE_7	; Flip to symbol page
	ld hl,buffer1		; Clear buffer
	ld b,9			;
	call _zeromem		;
	pop hl			;
	ld bc,-$05		;
	add hl,bc		; Point at name length byte
	ld b,(hl)		; Put name length into b
	dec hl			; Move to beginning of name
	ld de,buffer1		; Store in buffer1
	call dnloop		; Copy to buffer1, right way
(backwards VAT)
	call find_first_free	; Setup page to write to
	jp c,pe2_exists		;
	ld hl,264		;
	ld (numba),hl		;
	xor a			;
	ld (pstart),a		;
	call send_sfe		; Setup chip for data
	ld bc,4			; Send four byte security code
	ld hl,secs		; Start page
	call ssfe_loop		; Send it...
	ld bc,8			; Always send 8 bytes for name...
0 padded
	ld hl,buffer1		;
	call ssfe_loop		; Send it to EEPROM
	pop hl			; Get hl back
	ld a,(hl)		; Type byte...
	cp $12			; Program
	jr z,put_e2_prog	;
	cp $0C			;
	jr z,put_e2_stng	;
	ld hl,$302A		;
	ld (_penCol),hl		;
	ld hl,vunkn		;
	jp disp_pause_exit	;
put_e2_prog:
	ld a,$08		; 86 Program type
	jr send_type_byte	;
put_e2_stng:
	ld a,$0A		; 86 String type
send_type_byte:
	di			; Disable interrupts
	call send_byte		; Send byte
	ei			;
	dec hl			; Keep using same hl...
	ld e,(hl)		;
	dec hl			;  MidSB address byte...
	ld d,(hl)		;
	dec hl			;  MostSB addr byte
	ld a,(hl)		;
	ex de,hl		; Overwrite hl now that its pushed
	push af			; With TI-85, we won't need all
this
	push hl			; paged memory stuff...
	call _get_word_ahl	;
	ld (size),de		;
	pop hl			;
	pop af			;
	call inc_ahl_word	; Increase by two
	call _load_ram_ahl	; Convert to ASIC, swap in right RAM
page
	ld (datptr),hl		; Backup pointer
	ld hl,(size)		;
	ld a,h			; Send size to EEPROM...
	di			;
	call send_byte		;
	ld a,l			;
	call send_byte		;
	ei			;
	ld bc,0250		;
	or a			;
	sbc hl,bc		;
	jp c,one_page_total	; Put last page (pad if needed)
	inc hl			; Subtract 249
	ld (size),hl		;
	ld bc,249		; We'll be sending that many
	ld hl,(datptr)		;
	call ssfe_loop		; Send em
	ld (datptr),hl		; Store back... (loop handles
paging)

send_big_loop:
	call update_e2var	; Update UI
	call e2_dlay		; Give it time to write
	ld hl,(page)		; On to next page
	inc hl			;
	ld (page),hl		;
	ld hl,0264		;
	ld (numba),hl		;
	xor a			;
	ld (pstart),a		;
	call send_sfe		;
	ld bc,4			;
	ld hl,secc		; Send four security code bytes
	call ssfe_loop		;
	ld hl,(size)		;
	ld bc,0261		;
	or a			;
	sbc hl,bc		;
	jr c,put_one_more	;
	inc hl			; Subtract 260...
	ld (size),hl		;
	ld hl,(datptr)		;
	ld bc,260		; Send 260...
	call ssfe_loop		; Send 260 bytes using ahl
	ld (datptr),hl		;
	jr send_big_loop	; Keep doing 260 at a time...

put_one_more:
	ld bc,(size)		; Number left... less than or = 260
	ld hl,(datptr)		;
	call ssfe_loop		;
	ld de,(size)		;
	ld hl,0260		;
	or a			;
	sbc hl,de		;
	ld b,h			;
	ld c,l			;
	call erasep_ldi		; Pad with $FFs
	jr exit_pe2		; Bail

one_page_total:
	ld bc,(size)		;
	ld hl,(datptr)		;
	call ssfe_loop		;
	ld de,(size)		;
	ld hl,0249		;
	or a			;
	sbc hl,de		;
	ld b,h			;
	ld c,l			;
	call erasep_ldi		;

exit_pe2:
	ld hl,$302A		;
	ld (_penCol),hl		;
	ld hl,vsent		;
disp_pause_exit:
	call D_ZM_STR		; Overwrite previous
	jp exitpause		; Return, pausing before... stack ok

pe2_exists:
	inc sp			; Undo push hl
	inc sp			;
ge2_exists:
	ld hl,$302A		;
	ld (_penCol),hl		;
	ld hl,vexists		;
	jr disp_pause_exit	;

; Scans for a file/end of space
; Returns with z set if last page found
; Returns with c set if page of variable found	
find_first_free:
	ld de,0			; Start at 0...
	ld (page),de		;
find_ff_loop:
	ld hl,8			; And now name
	ld (numba),hl		;
	ld a,4			;
	ld (pstart),a		;
	ld hl,buffer2		;
	call get_sfe		;
	call cmp_buf1_buf2	; Compare with name from user
	ret c			; If there is a match, carry set;
return
	call get_e2size		; Get size
	ld a,l			; Are both size bytes $FF?
	and h			;
	cp $FF			; If it is, this is a blank page...
	ret z			; Return, we found last page
	call mv2nextsp		; Check next page...
	jr find_ff_loop		;	

cmp_buf1_buf2:			; Check if buffer1/buffer2 are
equal
	ld b,8			; compare 8 bytes
	ld hl,buffer1		;
	ld de,buffer2		;
cmp_loop:
	ld a,(de)		;
	ld c,(hl)		;
	cp c			;
	jr nz,no_match		; Only takes one to make them
different..
	inc hl			;
	inc de			;
	djnz cmp_loop		; ... Takes 8 to make them same
	scf			; They match... return with carry set
	ret			;

no_match:
	or a			; Return with carry cleared
	ret			;

update_e2var:
	ld hl,$152A		;
	push hl
	ld (_penCol),hl		;
	ld hl,space		;
	call D_ZM_STR		; Overwrite previous
	pop hl			;
	ld (_penCol),hl		;
	ld hl,(page)		; Page we're on now...
	call vputHL		; Display it
	ld hl,$1B2A		;
	push hl
	ld (_penCol),hl		;
	ld hl,space		;
	call D_ZM_STR		; Overwrite previous
	ld hl,$1B30		;
	ld (_penCol),hl		;
	ld hl,space		;
	call D_ZM_STR		;
	pop hl			;
	ld (_penCol),hl		;
	ld hl,(size)		; Page we're on now...
	jp vputHL		; Display it

; Increases ahl by 2, not 1
inc_ahl_word:
;	push de			; Don't waste cycles saving de
	ld de,$0002		; Add 2...
	add hl,de		;
;	pop de			;
	adc a,$00		; Then add on carry
	ret			;


___________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com/getjuno.html
or call Juno at (800) 654-JUNO [654-5866]


References: