A86: challenge


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

A86: challenge



I have a big problem.  I have been working on this for over 2 hours trying
to figure out what the problem is.  So I was wondering if you could help me
out.  I wrote this program, and the only bug now seems to be that when I
press the exit button it doesn't exit.  Instead it does some wierd stuff.
Here is the code if you can see the problem let me know.  The attachment is
the actual asm file.  Also if you have any other suggestions let me know.
One last thing, I am only a beginner!!!  By the way all of the other buttons
work fine.


;my first bitmap
;by Brian Thompson

#include "asm86.h"
#include "ti86asm.inc"

.org _asm_exec_ram

Start:
     call _clrLCD
     ld bc,$0500
     ld (_curRow),bc
     ld hl,Title
     call _puts
     ld bc,$0203
     ld (_curRow),bc
     ld hl,Author
     call _puts
     ld bc,$220D
     ld (_penCol),bc
     ld hl,Email
     call _vputs
    KeyST:
     call GET_KEY
     cp K_ENTER
     jr nz,KeyST

CursorST:
     call _clrLCD
     ld bc,$3232
     ld ($CFAB), BC
     push bc
     ld de, Cursor
     call DrawSprite
     pop bc
     pop bc

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Key:
     call GET_KEY
     cp K_EXIT  ;Here is the exit comparison!!!!!!!!!
     ret z
     cp K_UP
     jr z,UP
     cp K_DOWN
     jr z,DOWN
     cp K_LEFT
     jr z,LEFT
     cp K_RIGHT
     jr z,RIGHT
     jr Key

UP:
     ld de, Cursor
     ld bc,($CFAB)
     call DrawSprite
     ld bc,($CFAB)
     dec c
     ld ($CFAB),bc
     ld de, Cursor
     call DrawSprite
     jr Key

DOWN:
     ld de, Cursor
     ld bc,($CFAB)
     call DrawSprite
     ld bc,($CFAB)
     inc c
     ld ($CFAB),bc
     ld de, Cursor
     call DrawSprite
     jr Key

LEFT:
      ld de, Cursor
     ld bc,($CFAB)
     call DrawSprite
     ld bc,($CFAB)
     dec b
     ld ($CFAB),bc
     ld de, Cursor
     call DrawSprite
     jr Key


RIGHT:
     ld de, Cursor
     ld bc,($CFAB)
     call DrawSprite
     ld bc,($CFAB)
     inc b
     ld ($CFAB),bc
     ld de, Cursor
     call DrawSprite
     jp Key


;From the Draw Sprite demo becasue i dont know how.
;If someone would like to let me know how to display a sprite
;(the actual command to display it) please tell me
;this is not my code
DrawSprite:      ;©1997 James Yopp.  If you use it, leave this
        push    hl
        push    de
        push    bc
        call    FP
        ex      de, hl
        ld      b, (hl)
        inc     hl
DS_Loop:
        push    bc
        push    af
        push    af
        ld      b, (hl)
        ld      c, (hl)
        add     a, a
        jr      C, DS_EndB
DS_BLoop:
        SRL     b
        add     a, a
        jr      nc, DS_BLoop
DS_EndB:
        pop     af
DS_CLoop:
        SLA     c
        SRL     a
        jr      nc, DS_CLoop
        inc     hl
        ld      a, (de)
        xor     b
        ld      (de), a
        inc     de
        ld      a, (de)
        xor     c
        ld      (de), a
        push    hl
        ld      hl, 15
        add     hl, de
        ex      de, hl
        pop     hl
        pop     af
        pop     bc
        DJNZ    DS_Loop
        pop     bc
        pop     de
        pop     hl
        ret
FP:       ;©1997 James Yopp.  If you use it, leave this comment in the
        push    de
        push    bc
        push    bc
        ld      h, $FC
        SRL     b
        SRL     b
        SRL     b
        ld      l, b
        ld      b, c
        ld      de, 16
        xor     a              ;A very short way of doing ld a, 0.  This,
however,
BLoop:                         ;updates the flags (sometimes a bad thing)
        add     hl, de
        cp b                   ;If I didn't use this stuff, the top display
line
        jr      Z, XitLoop     ;wouldn't work.  b would be decreased,
leaving 255.
        dec     b              ;If you won't use the top line, change it.
        jr      BLoop
XitLoop:
        pop     bc
        ld      a, b
        and     %00000111
        ld      b, a
        inc     b
        ld      a, %00000001
ALoop:
        RRCA
        DJNZ    ALoop
        pop     bc
        pop     de
        ret
;my code starts again HERE!!!!!!!!!!!!!!!!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Author:
 .db "By Brian Thompson",0

Email:
 .db "CAESAR.CAT@worldnet.att.net",0

Title:
 .db "The Cursor",0

Cursor:
.db 8
.db %01100000
.db %01110000
.db %01111000
.db %01111100
.db %01111000
.db %00011100
.db %00001110
.db %00000111

.end












working3.asm


Follow-Ups: