Re: A92: Quitting ASM or not -- please answer these questions


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

Re: A92: Quitting ASM or not -- please answer these questions




At 14:15 1998-12-05 -0500, you wrote:
>
>from: Creating Tables
>l printed out J.Mardell's guide on 8.5x14 in. paper, l've read it all and
>things make sense!  However a couple of things are missing...
>1.	Can l make a matrix like array in plusshell programs?  ls it defined the
>same way?

In assembly an array is just a block of memory that you manage in a
specific way, with a starting adress and an offset that is calculated from
which cell you wish to access. It's up to you how big those cells are and
*exactly* what they contain down to the last byte.

>2.	How can l display a sprite?  lf this is done by way of a library, and the
>.h file tells how [input], don't bother with this question.

There are libraries that do this. If you want your own internal routine
it's just a matter of plotting the relevant sprite data onto the screen, or
into a buffer that is later copied to the LCD memory. The only problem is
that the sprite data needs to be shifted to get it to the exact pixel
(x-coordinate) since the 89/92 uses bitplane (one bitplane, actually :)
graphics.

>from: Library Input/Output
>Where can l find the parameters for all the functions in the new plusshell
>libraries?

Normally they should be .h-files accompanying the libraries, but both
PlusShell and DoorsOS have, annoyingly enough, put them in the docs. Look
there. If you can't find it, feel free to contact me or the list.

>from: Displaying sprites, help me and SimTown will be asm
>When making games (like Zelda) do asm programmers use arrays to place the
>sprites onto the screen at given locations?

Arrays for what? Storing the sprites or plotting them?

>from: Using a 2 dimensional array to put sprites
>How can l sort of use "indirection" to put a sprite at a location?  Realize
>that part of the code would not work because l had to make it up, but l'll
try
>to explain what l'm doing.  table is a 50x50 array.  d1 is the row, d2 the
>col.
>
>lea     table(PC),a0  ; Let A0 point at the table
> mulu    #100,d1       ; One row is 100 bytes (50 words). We must use
>                       ; MULU to get the right offset. If each row was
>                       ; 128 bytes, we could have shifted instead (faster).
> adda    d1,a0         ; Add the rowoffset to the pointer
> lsl.w   #1,d2         ; Multiplicate the column with 2 (same reason as
above)
> move.w  0(a0,d2),d0   ; Get the word and store it in d0 (l wrote this
>comment!)
>
>Now: let's say that d0 equals 00000001 (which in my SimTown game l might want
>to be the code for a road tile).  l know that my label for the sprite can't
>start with a number, but l don't want to:
>cmp d0,00000001
>beq road_tile
>cmp d0,00000002
>beq clear_land
>lnstead, l want to somehow jump to what d0 equals.  so when d0 equals
00000001
>l want to somehow convert that value into a label it can jump to.

You can build a table with the start adresses to everything. I did this in
Tinx2 for the built-in sprite language:

First we define some "commands":
SP_SET_FLAGS	EQU	IP_SET_FLAGS-IPS	;Flag bits to set
SP_CLEAR_FLAGS	EQU	IP_CLEAR_FLAGS-IPS	;Flag bits to clear
SP_JUMP_IF	EQU	IP_JUMP_IF-IPS		;Flag bits to check, Goto
SP_JUMP_IF_NOT	EQU	IP_JUMP_IF_NOT-IPS	;Flag bits to check, Goto

Now if a piece of data (or, in your case, a register) contains the value
SET_FLAGS you can use the following code to jump:
	lea		IPS,a4	;Relative adress of .92p program start
	move.w		(a1)+,d1	;Get command
	jmp		0(a4,d1.w)

... other code ...

IP_SET_FLAGS:
 .... code for SET_FLAGS...

IP_CLEAR_FLAGS:
 .... code for CLEAR_FLAGS


The label IPS must be somewhere in the program before the EQU:s above.


If you want more help please contact the list, or me by mail or ICQ (419327)


Niklas Brunlid - http://www.efd.lth.se/~e96nbr
PQF Quote follows:

He did of course sometimes have people horribly tortured to death, but this
was considered to be perfectly acceptable behaviour for a civic ruler and
generally approved of by the overhelming majority of citizens. [footnote:
The overhelming majority of citizens being defined in this case as everyone
not currently hanging upside down over a scorpion pit]
        -- (Terry Pratchett, Sourcery)


References: