Re: A83: Help with my rpg


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

Re: A83: Help with my rpg




I wrote a little matrix function that might help.  Also, getting from R is
easy too.  The code to recall R comes straight from AsmGuru, only I
changed the var from W to R

call _zerooop1
ld hl,op1+1
ld (hl),'R'     ; or any other var
call _rclvarsym ; op1 / op2 -> value
call _convop1
ex   de,hl
call _disphl

All tutorials Copyright (c) James Matthews 1998, unless specified.

Here's the matrix program.  I commented almost every line.

Hope this helps you

Jeremy

.NOLIST                 ; Defines area which isn't code.
#define end .end
#define END .end
#define equ .equ
#define EQU .equ
#include "ti83asm.inc"
#include "tokens.inc"
_errundefined .equ 467Bh

.LIST                   ; Defines area which IS code.
.org 9327h

        ld a,tMatA      ;load A with the matrix you want to write to
        ld b,5          ;load B with the number of rows to write
        ld c,5          ;load C with the number of columns to write
        ld de,matdata   ;load DE with a pointer to the data to copy
        call matcall    ;call the function
        ret             


matdata:                ;data to copy to matrix
        .dw 1,2,3,4,5   ;stored in words
        .dw 6,7,8,9,10
        .dw 11,12,13,14,15
        .dw 16,17,18,19,20
        .dw 21,22,23,24,25


matcall:
        ld (ptr),de     ;set up pointer to data
        inc b           ;fix max rows
        inc c           ;and cols
        ld (maxrowcol),bc ;put them in memory
        ld hl,OP1       ;load the pointer to OP1 into HL
        ld (hl),2       ;set it up with the name of the matrix
        inc hl          ;the 2 is the Matrix object type
                        ;for some reason it's not equated in ti83asm.inc or tokens.inc
        ld (hl),tVarMat ;tVarMat=1st of 2 tokens for matrices
        inc hl
        ld (hl),a       ;a has the other one
        inc hl
        ld (hl),0       ;null terminated
        call _chkfindsym;look up symbol
        jp c, _errundefined ;ERR:UNDEFINED if undefined
        push de         ;save pointer to matrix
        ld bc,0101h     ;load BC to first row, first col
        push bc         ;save it

loope:
        ld hl,(ptr)     ;load HL with the pointer to the matrix data
        ld e,(hl)       ;load DE with word that HL points to
        inc hl          ;the hard way
        ld d,(hl)       ;because Z80 won't allow me to simply ld de,(hl)
        ex de,hl        ;now switch them because I want DE in HL and I can't ld hl,de
        call _setxxxxop2;copy HL into OP2
        call _op1exop2  ;exchange OP1 and OP2
        pop bc          ;restore pointer to row/col of matrix
        pop de          ;restore pointer to matrix start
        push de         ;save it again
        push bc         ;  "    "
        call _puttomat  ;put data in HL to matrix row B col C
        ld hl,ptr       ;load pointer into HL
        inc (hl)        ;at last Z80 is helpful
        inc (hl)        ;     "        "
        pop bc          ;restore row/col
        inc c           ;increment col
        push bc         ;save it again
        ld a,c          ;copy into A because Z80 won't compare with C
        ld bc,(maxrowcol) ;load max row/col into BC
        cp c            ;compare our current row/col with max
        jr nz,loope     ;if not at max, loop again

        pop bc          ;restore row/col (it's already in there, this is just cleaning up the stack)
        ld c,1          ;reset the column to 1
        inc b           ;increment the row
        push bc         ;save it
        ld a,b          ;move row into A
        ld bc,(maxrowcol) ;load max row/col
        cp b            ;compare current row with max row
        jr nz,loope     ;loop if not at max

        pop bc          ;clean up
        pop de          ;the stack
        ret             ;and return

ptr:
        .dw 0
maxrowcol:
        .dw 0
        ret

.end

On Wed, 30 Aug 2000 Mike3465@aol.com wrote:

> 
> Ok heres my idea: I'm a very good basic programmer and i'm a beginner at 
> ASM(actually i just don't know how to do what i want to do) But my idea for a 
> rpg will be that, Rendering will all be done in asm(for speed), and the other 
> stuff, that dosn't really rely on drawing(ex battles(besides the enemies), 
> menu's, that sort of stuff) would be programmed in basic.
> 
> but i was wondering if anyone could help me out by, either telling me how, or 
> just giving me the code(i would like this better but either way would be 
> fine), to do the following:
> 
> 1 input R ( a var that says which map to load)(it is set by the basic program)
> 2 the drawing program finds the correct data(it's only 1 screen wide and tall)
> 3 the drawing program then draws the tiles onto the screen
> 4 the drawing program finds the correct tileinfo( ex: 1= 
> nonpassable,2=special,0= passable)
> 5 The drawing program then saves that info into [A](for use with hit checking 
> and the like)
> 6 it then sends control back to the basic part of the program....
> 
> If anyone can help me with this then it would be a great help, it would be 
> even better if someone just gave me the code but i'll accept anything
> I can make a program that inputs 3 vars, and then displays your char easily 
> enough...so if anyone can help me with that i will be very gratefull.
> Thanks, Bye
> 





References: