Re: A89: Re: Tilemaps
[Prev][Next][Index][Thread]
Re: A89: Re: Tilemaps
----- Original Message -----
From: Matt Baker <po2084@hotmail.com>
To: <zeromusmog@home.com>
Sent: Tuesday, December 14, 1999 7:30 PM
Subject: Re: A89: Re: Tilemaps
> I would be interested in reading the code.
>
> thx
>
> Matt.
Alrighty, here we go, dug deep from my archives... whatever I have here
might be my latest frantic attempt to get it to work and not necessacarily
follow sound logical procedures. Or something like that. So if I did
something really stupid... well, I probably knew it wouldn't work before I
tried it, but just to make sure...
I haven't commented the loop part yet, because, well, I have no idea how to
do it yet.
I also know that the sprite routine is limited and slow. The goal of this
"tutoricode" is not to be as efficient as possible, but to be as easy to
understand as possible. ^_^
-------------------------------
BELOW EXAMPLE IS (C)1999 MOGSOFT, INC.
WORK IN PROGRESS.
DO NOT DISTRIBUTE, ESPECIALLY WITH MODIFICATIONS, WITHOUT EXPRESS WRITTEN
PERMISSION OF MOGSOFT, INC.
By: ZeromusMog@home.com
-------------------------------
include "tios.h"
include "util.h"
include "graphlib.h"
xdef _main
xdef _comment
xdef _ti89
Disp macro ;A macro. This does not save bytes. Every time this
macro is called, it is included in the program again.
move.w \3,-(a7) ;Set the font to display the words in. Can be white on
black, black on white, "xor" (inversed), and some other stuff. This is
loaded to the stack.
pea \4(pc) ;Point to the string to display
move.w \2,-(a7) ;Load (push) the vertical coordinate to the stack
move.w \1,-(a7) ;Load (push) the horizontal coordinate to the stack
jsr tios::DrawStrXY ;call tios and put the string on the screen
lea 10(a7),a7 ;Fix the stack pointer. This gets rid of the junk
pushed earlier. Since 10 bytes are pushed to the stack
(font(2)+pointer(4)+xcoord(2)+ycoord(2)=10), 10 is added to the stack
pointer, as it goes backwards when stuff is pushed to it.
endm ;End the macro.
_main:
jsr util::zap_screen
lea Screen1,a1
clr.l d0
clr.l d1
bsr Loop1
jsr util::idle_loop
rts
Loop1:
lea SpriteTable(pc),a0
bsr PutSprite
add.l #1,d0
cmp #22,d0
ble Loop1
clr.l d0
add.l #1,d1
cmp #12,d1
ble Loop1
rts
PutSprite:
move.l #LCD_MEM,a1 ;Load the video memory into a1
add.l d0,a1 ;Add up the video memory and the column
mulu #240,d1 ;Multiply the row by 240 (8 lines of video memory-
30 bytes/line*8 lines)
add.l d1,a1 ;Add up the video memory and the row
move.b (a0),(a1) ;Load line 1 of the sprite into video memory
move.b 1(a0),30(a1) ;Load line 2 of the sprite into video memory
move.b 2(a0),60(a1) ;Load line 3 of the sprite into video memory
move.b 3(a0),90(a1) ;Load line 4 of the sprite into video memory
move.b 4(a0),120(a1) ;Load line 5 of the sprite into video memory
move.b 5(a0),150(a1) ;Load line 6 of the sprite into video memory
move.b 6(a0),180(a1) ;Load line 7 of the sprite into video memory
move.b 7(a0),210(a1) ;Load line 8 of the sprite into video memory
divu #240,d1
rts
_comment: dc.b "Mogsoft Tilemap Example v1.0",0
Sprite1:
dc.b %11111111
dc.b %10000001
dc.b %10000001
dc.b %10000001
dc.b %10000001
dc.b %10000001
dc.b %10000001
dc.b %11111111
Sprite2:
dc.b %10000001
dc.b %01000010
dc.b %00100100
dc.b %00011000
dc.b %00011000
dc.b %00100100
dc.b %01000010
dc.b %10000001
Screen1:
dc.b 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1
dc.b 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
References: