Re: A83: External Level


[Prev][Index][Thread]

Re: A83: External Level




Here you go... Once you have this it isn't difficult anymore... All you 
need is to have a unique "header" to the file, and search for that at 
PROGPTR. Then make sure to add the length in bytes of your header to de. 
Then you are at all the data in the program. You could do other things 
with this than just external levels.

-Revenant

External Level:

.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
.org 9327h
	.db "External Level for My Game"
.end
END

;---------= Detect Program =---------
; input:
;	hl=place to start looking
;	ix->first line of data (0 terminated)
; output:
;	de=place stopped + 1
;	hl->program data (after the string)
;	z=0 if found, z=1 if not found.
;	most registers are messed up
detect:
chgwlp:	ld	(data),hl	; in case a program is found
	ld	a,(hl)		; 	but no good.
	and	%00011111
	dec	a	; 1
	jr	z,list
	cp	$0D-1	; D
	jr	z,list
	sub	4	; 5
	jr	z,nogood2
	dec	a	; 6
	ret	nz
cwchck:	dec	hl		; move to ptr (skip var type)
	push	hl
	ld	b,(hl)
	dec	hl
	ld	c,(hl)
	ld	h,c
	ld	l,b	; now we are at the program
	inc	hl	; skip file length
	inc	hl
	push	ix	; slow... but small
	pop	de
ckprog:	ld	c,(hl)
	ld	a,(de)
	cp	c
	jr	nz,nogood
	inc	de
	inc	hl
	ld	a,(de)
	or	a
	jr	nz,ckprog
	ex	de,hl
	pop	hl	; back at the fat
	dec	hl
	dec	hl
	ld	b,(hl)		; length of name
	inc	b		; move to next program as well in case the
skprog:	dec	hl		; user doen't want this world
	djnz	skprog
	ex	de,hl
	xor	a
	ret
nogood2:
	push	hl
nogood:	pop	hl
	ld	hl,(data)
list:	dec	hl		; lists enter here to be skipped
	dec	hl
	dec	hl
	ld	b,(hl)
nogdlp:	dec	hl
	djnz	nogdlp
	dec	hl		; next item
	jr	chgwlp

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com