Re: A86: Maping a game with .db?


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

Re: A86: Maping a game with .db?



Yes, here is a good example (not by me!!)(by Tercero) It reads 16x8 level maps.
#include "asm86.h"
#include "ti86asm.inc"

.org _asm_exec_ram

Start:
call _clrLCD
ld a, 15
Loop:
ld d, a
ld hl, Level1
ld b, 0
ld c, a
add hl, bc
ld a, (hl)
ld b, 8
or a
ShiftLoop:
srl a
call c, DispBlock
djnz ShiftLoop
ld a, d
dec a
ret m
jp Loop

DispBlock:
push af
push bc
push de
push hl
ld hl, $0000
dec b
ld h, b
ld a, d
and $01
cp 0
jp z, Padone
ld a, 8
add a, h
ld h, a
Padone:
ld l, d
srl l
ld de, Block
call AlignSprite
pop hl
pop de
pop bc
pop af
ret

;Data______________________________________________
Level1:
.db %11111111,%11111111
.db %10000000,%00000001
.db %10001100,%00110001
.db %10000000,%00000001
.db %10010000,%00001001
.db %10001111,%11110001
.db %10000000,%00000001
.db %11111111,%11111111
Block:  .db %11111111,%10000001,%10111101,%10100101
.db %10100101,%10111101,%10000001,%11111111

;AlignSprite_____________________
;Input: DE = Sprite Address     |
;       H = X-Coord (0-15)      |
;       L = Y-Coord (0-7)       |
;Output: Sprite drawn to screen |
;Destroyed: none                |
;--------------------------------
AlignSprite:
push af
push bc
push de
push hl
ld a, h
ld h, l       
ld l, a
sla l
srl h
rr l
ld bc, $FC00
add hl, bc
ld b, 8
ASpriteLoop:
ld a, (de)
ld (hl), a
inc de
ld a, 16
add a, l
ld l, a
jp nc, ASNoinc
inc h
ASNoinc:
djnz ASpriteLoop
pop hl
pop de
pop bc
pop af
ret


.end
--------------
Jbrett
tbarwick@esn.net
http://ww2.esn.net/~tbarwick
I just added a TI-86 page, Check it out!!!  
-----Original Message-----
From: Dave <scheltem@aaps.k12.mi.us>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Thursday, September 10, 1998 6:38 PM
Subject: Re: A86: Maping a game with .db?

Okay well what i ment was is it possible to control a screen by bytes.  say i have
.db 10011110
and everytime 1 is shown i load in a picture of a block and 0 I load a black space? 
 
-----Original Message-----
From: assets <assets@eden.rutgers.edu>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Thursday, September 10, 1998 3:11 PM
Subject: Re: A86: Maping a game with .db?

You still have to put a sprite for each block (it's not that slow ... really :-).  You might want to consider writing a specialized sprite routine.  For instance, if you don't have to put sprites between bytes of video memory (it sounds like you want sprites every 8 pixels), then you don't need a findpixel bitmask.  Your specialized routine might input block type, row and col (row / col being every 8th pixel).

Dave wrote:

 Okay i have a pretty simple question (it seems as always) but lets say that i wantto have a map for a game, but instead of just making a huge title screen i want to make it so that i have "blocks" so to speak.  In each block i could have a different picture displayed or the same one displayed.  This way i would not have to call a sprite routine a hundred times and putsprite at b=2 c=1.  If any one gets what i am talking about please help me out.  I know that i have to define the bytes .db 01110011 and say evertime 1 appears show a block that is 8*8 but i don't really get how to use the defined bytes in this way.  I am sure that this is what is commonly used in games, but i have not found info about it.  Thanks for the help.Dave
******************************
Basic Programing Center
http://www.geocities.com/TimesSquare/Ring/8708/
ICQ #16817590