RE: A85: NASRWarp acting strangely


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

RE: A85: NASRWarp acting strangely



Here are the portions of my ASM program source that will hopefully be 
helpful in finding the problem I'm having with NASRWarp. The problem is 
that whenever the routine is called, instead of the sprite being displayed, 
two small rows of pixels appear near the lower-left corner of the screen. 
The rows are not solid, but filled with randomly placed pixels, and the 
positions of the individual pixels change when the routine is called with 
different parameters. The pixels always appear in the arrangement of two 
rows in the same place on the screen, though.

A few notes: I changed one of the last lines of NASRWarp from "jr 
 nz,YLoop" to "JUMP_NZ(YLoop)" because TASM gave a relative jump out of 
range error. I use the two memory locations SpriteOnLoc and SpriteOffLoc, 
defined in text memory for my program, to contain pointers within my 
program to the sprite I want to draw, with (PROGRAM_ADDR) already added. So 
before I call NASRWarp, I just have to execute "LD  HL,(SpriteOnLoc)". I 
then inserted an "LD  DE,(PROGRAM_ADDR)", because it looked like NASRWarp 
needed that when I looked at the routine.

Change your email program's font to fixed-width to view the code better. 
The ".." in the code indicates I have cut out a section of the code that 
seemed to be irrelevant, so this email was not 20K :).

---Start of selected portions of ASM source---
#include ti-85.h

.org 0
.db "Fliptile v1.0",0

..

SpriteOffLoc = $80E2
SpriteOnLoc = $80E4

..
CursorX = $86CB
CursorY = $86CC

TempLine = $80E7
PicCoor = $80E8
offset = $80EA
NASR_Status = $80EB

Start:
	ROM_CALL(BUSY_ON)
	LD   HL,$8353   ; Bit set so displayed text would not
	RES  1,(HL)      ; interfere with text memory
	LD   A,4
	OUT  (5),A
..

DrawSprite:
	BIT  0,A
	CALL_Z(DrawSpriteOff)
	CALL_NZ(DrawSpriteOn)
	RET

DrawSpriteOff:
	PUSH AF
	PUSH BC
	PUSH DE
	LD   A,1
	LD   (NASR_Status),A
	PUSH DE
	POP  BC
	LD   HL,(SpriteOffLoc)
	LD   DE,(PROGRAM_ADDR)
	CALL_(NASRWARP)
	POP  DE
	POP  BC
	POP  AF
	RET

DrawSpriteOn:
	PUSH AF
	PUSH BC
	PUSH DE
	LD   A,1
	LD   (NASR_Status),A
	PUSH DE
	POP  BC
	LD   HL,(SpriteOnLoc)
	LD   DE,(PROGRAM_ADDR)
	CALL_(NASRWARP)
	POP  DE
	POP  BC
	POP  AF
	RET

..

DisplayCursor:
	LD   HL,(PROGRAM_ADDR)
	LD   DE,CursorVertLine
	ADD  HL,DE
	LD   (SpriteOffLoc),HL
	LD   HL,(PROGRAM_ADDR)
	LD   DE,CursorHorzLine
	ADD  HL,DE
	LD   (SpriteOnLoc),HL
	CALL_(DrawCursor)
	RET

HideCursor:
	LD   HL,(PROGRAM_ADDR)
	LD   DE,CursorVertOff
	ADD  HL,DE
	LD   (SpriteOffLoc),HL
	LD   HL,(PROGRAM_ADDR)
	LD   DE,CursorHorzOff
	ADD  HL,DE
	LD   (SpriteOnLoc),HL
	CALL_(DrawCursor)
	RET

DrawCursor:
	LD   A,(CursorX)
	LD   B,A
	LD   A,15
DCursMultLoop1:
	ADD  A,6
	DJNZ DCursMultLoop1

	LD   D,A
	LD   A,(CursorY)
	LD   B,A
	LD   A,13
DCursMultLoop2:
	ADD  A,6
	DJNZ DCursMultLoop2

	LD   E,A
	PUSH DE
	POP  BC
	LD   A,1
	LD   (NASR_Status),A
	LD   HL,(SpriteOnLoc)
	LD   DE,(PROGRAM_ADDR)
	PUSH BC
	CALL_(NASRWARP)
	POP  BC
	DEC  C
	LD   A,1
	LD   (NASR_Status),A
	LD   HL,(SpriteOffLoc)
	LD   DE,(PROGRAM_ADDR)
	PUSH BC
	CALL_(NASRWARP)
	POP  BC
	LD   A,C
	SUB  5
	LD   C,A
	LD   A,1
	LD   (NASR_Status),A
	LD   HL,(SpriteOnLoc)
	LD   DE,(PROGRAM_ADDR)
	PUSH BC
	CALL_(NASRWARP)
	POP  BC
	LD   A,C
	ADD  A,5
	LD   C,A
	LD   A,B
	ADD  A,6
	LD   B,A
	LD   A,1
	LD   (NASR_Status),A
	LD   HL,(SpriteOffLoc)
	LD   DE,(PROGRAM_ADDR)
	CALL_(NASRWARP)
	RET

..
(NASRWarp pasted into program)

(various .db's for text and sprites, one sprite shown here as an example)

AnimToOff1Sprite:
.db 1,4,5
.db %00111000
.db %11111000
.db %11111000
.db %11111000
.db %00111000

..

.end

---End of selected portions of ASM source---
________________

Jeff Tyrrill
http://tyrrill-ticalc.home.ml.org/
http://ti-files.home.ml.org/