A86: Can anyone tell me whats wrong with this?


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

A86: Can anyone tell me whats wrong with this?






#include "ti86asm.inc"
#include "asm86.h"
#include "Ram86.inc"
#include "ti86math.inc"
#include "ti86ops.inc"
#include "ti86abs.inc"
#include "ti86und.inc"
.org _asm_exec_ram
clipmask 	= _textShadow		; [1] used by ASCR
rows2put 	= _textShadow + 1	; [1] ...
bitmask  	= _textShadow + 2	; [1] ...
currspr	 	= _textShadow + 3	; [2] current sprite to draw
background 	= _textShadow + 5	; [8] background behind the sprite 
change:  
    ld b,15
    cp 0
    jp z,Startthefun
    ld a,($C008)	; load contrast value
	inc a	; increase the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
     ld a,($C008)	; load contrast value
	inc a	; increase the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
     ld a,($C008)	; load contrast value
	inc a	; increase the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
     ld a,($C008)	; load contrast value
	dec a	; deacrease the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
    dec a	; deacrease the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
    dec a	; deacrease the contrast
	ld ($C008),a	; write it back to memory
	out (2),a	; and to the port
    jp Startthefun
     
Startthefun:
 ld a,0
 call _flushallmenus			; close any open menus
 call _runindicoff          	; turn off the run indicator



 ld b,57						; set starting X coord
 ld c,53						; set starting Y coord
 ld hl,SprRi					; the first time the right sprite is drawn
 ld (currspr),hl				; set starting sprite
 ld de,background				; we will save the background at this address
                     			; draw the sprite for the first time

Loop:
 halt				; besides the sprite clipping this is the only copyed part
 out (1),a			;
 ld a,%01111110		; 
 nop \ nop			; 
 in a,(1)			; 
 rra				;
 jr nc,Down			; 
 rra				; 
 jr nc,Left			;
 rra				; 
 jr nc,Right		; 
 rra				; 
 jr nc,Up			; 
 ld a,%00111111		; 
 out (1),a			; 
 nop \ nop			; 
 in a,(1)			; 
 bit 6,a			; 
 jr nz,Loop			; 
 call _clrLCD		; 
 ret				;

Up:
 ld a,c				; load the coord for check
 or a				; is it 0?
 jr z,Loop			; then we don't want to move
 call Erase			; erase the old sprite
 dec c				; decrease Y coord
 jr Draw			; draw sprite

Down:
 ld a,c				; load the coord for check
 cp 56				; is it 56?
 jr z,Loop			; then we don't want to move
 call Erase			; erase the old sprite
 inc c				; increase Y coord
 jr Draw			; draw sprite

Left:
 ld a,b				; load the coord for check
 or a				; is it 0?
 jr z,Loop			; then we don't want to move
 call Erase			; erase the old sprite
 dec b				; decrease X coord
 ld hl,SprRi		; point to sprite for left direction
 ld (currspr),hl	; save new sprite
 jr Draw			; draw sprite

Right:
 ld a,b				; load the coord for check
 cp 120				; is it 120?
 jr z,Loop			; then we don't want to move
 call Erase			; erase the old sprite
 inc b				; increase X coord
 ld hl,SprRi	; point to sprite for right direction
 ld (currspr),hl	; save new sprite
 jr Draw			; a JR DRAW is not needed, we fall through...				

Draw:
 push bc			; save coords
 ld hl,(currspr)	; load the pointer of the sprite to draw
 ld de,background	; we will save the background at this address
 jr Draw         	; draw the masked sprite and save the background
 pop bc				; restore coords
 jr Loop			; loop through the program

Erase:
 push bc			; save coords
 ld hl,background	; we need to redraw the background
 jr Draw	        ; draw the masked sprite and save the background
 pop bc				; restore coords
 ret				; return to what called us


SprRi:
	.db %00011000 ;Masked Sprite 8 by 16 regular sprites are 8 by 8
	.db %00100100
	.db %01000010
	.db %10011001
	.db %10011001
	.db %01000010
	.db %00100100
	.db %00011000
	.db %00011000
	.db %00111100
	.db %01100110
	.db %11011011
	.db %11011011
	.db %01100110
	.db %00111100
	.db %00011000


.end