Re: LZ: matrices


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

Re: LZ: matrices



Will Stokes (3D Diamond productions) wrote:
> 
>                                    wstokes@vertex.ucls.uchicago.edu
>                                    http://www.uic.edu/~hhstokes/index.html
>                                    Will Stokes
> 
>         Once again thanks to all of you out there who have provided  your
> own asm code or help on this list serve, your help and my prior experience
> have enabled me to get much better at it. I have only say four or so
> questions before I'm ready to complete my first game which will still take
> a while but will be very fun... just wait.
> Here are my latest q's:
> 
> 1:      matrices...I loved them in ti-basic because they were so helpful
> but I could never put strings into them. How can I do matrices in
> assembler and can I input strings? it must be similar to loading
> "variables" into TEXT_MEM.....right?


Yup, you can do matrices in asm. And they're much faster and much
smaller to.
If you want to put strings in them you must have pointers. Actually,
manipulating with strings in asm is not so easy.


You can put small matrices in the text_mem part, else you must use the
program memory. I'll try to give you an example. Don't know if it helps
ya.
It will probably not work. I wrote it online... You must fill up the
whole
array before calling ShowArray, else it won't look nice I think.


#include ti-85.h


StrArray = $80DF   ; Allocating 6 str pointers = 12 byte


.org 0
.db "Array of strings",0


 ld hl,String1
 xor a
 CALL_(PutStrInArray)
 ld hl,String2
 inc a
 CALL_(PutStrInArray)
 ld hl,String1
 inc a
 CALL_(PutStrInArray)
 ld hl,String3
 inc a
 CALL_(PutStrInArray)
 ld hl,String3
 inc a
 CALL_(PutStrInArray)
 ld hl,String2
 inc a
 CALL_(PutStrInArray)
 CALL_(ShowArray)
 ret 


PutStrInArray:         ; Puts string at HL (relativ addr) in array at
location A
 ld de,(PROGRAM_ADDR)
 add hl,de
 push hl
 ld h,0
 ld l,a
 sla l
 ld de,StrArray
 add hl,de
 pop de
 ld (hl),e
 inc hl
 ld (hl),d
 ret


ShowArray:              ; Shows 6 strings in the array
 ROM_CALL(CLEARLCD)
 ld hl,StrArray
 ld de,(PROGRAM_ADDR)
 add hl,de
 ld b,6
ShowStr:
 push hl
 call LD_HL_MHL        ; If hl=0, then no string
 ld de,(PROGRAM_ADDR)
 add hl,de     
 ld a,0
 ld (CURSOR_COL),a
 ld a,6
 sub b
 ld (CURSOR_ROW),a
 inc b
 ROM_CALL(D_ZT_STR)
 pop hl
 inc hl
 inc hl
 djnz ShowStr
WaitKey:
 call GET_KEY
 cp K_EXIT
 jr nz,WaitKey
 ret


String1:
 .db "This is string1",0
String2:
 .db "This is string2",0
String3:
 .db "This is string3",0


.end


> 
> 3:      Highscores I believe make games much much much better... but to do
> so the string/program is changing. Exactly how do I do this without
> resetting the highscore every time I play the game etc. etc. etc.??????


I haven't done it, but probably you just change somewhere in your own
program.
You must also update the chksum, or perhaps easier you use another byte
to
balance the chksum.
 


//Jimmy Mårdell <mja@algonet.se>


References: