A89: I've just about had it with 89 asm


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

A89: I've just about had it with 89 asm




Will someone please tell me why this doesn't work?  You're supposed to lose 
when the target gets down to 64, but you don't.  The bullet is supposed to 
fire when you press 2nd, but it doesn't.  Help me!

;Archer for Doors
;By Grant Elliott
;12/28/99

;libraries
    include "doorsos.h"
    include "userlib.h"
    include "graphlib.h"

;definitions
    xdef    _main
    xdef    _comment
    xdef    _ti89

;main program
_main:
Go:
    move.l  #3840,-(a7)
    jsr doorsos::HeapAlloc  ;Allocate 3840 bytes
    addq.l  #4,a7
    or.w    d0,d0
    beq exit_prgm       ;Check that memory was allocated
    move.w  d0,vid_handle
    doorsos::DEREF  d0,a0
    move.l  a0,vid_addr
    eor.l   d0,d0       ;clear d0
    move.l  d0,x_pos
    move.l  d0,y_pos
    move.l  #88,Bullet
    bsr anim_sprite
    bra IOH

anim_sprite:
    bsr ClearBuffer
    move.l  y_pos,d1
    move.l  x_pos,d0
    lea target(pc),a0
    bsr PutSprite       ;draw target
    move.l  Bullet,d1
    move.l  #76,d0
    lea shot(pc),a0
    bsr PutSprite       ;draw bullet
    bsr CopyBufferToScreen
    bsr Updatex
    bsr UpdateBullet
    cmp #88,Bullet
    beq get_key
    cmp.w   #4,d3
    beq Fire
    bra anim_sprite

Updatex:
    move.l  x_pos,d0
    addq.l  #1,d0
    move.l  d0,x_pos
    cmp #152,d0
    beq Updatey
    rts

Updatey:
    move.l  y_pos,d1
    addq.l  #8,d1
    move.l  d1,y_pos
    move.l  #0,x_pos
    cmp #64,d1
    beq Lose
    rts

UpdateBullet:
    move.l  Bullet,d1
    cmp #88,d1
    bne MoveBullet
    rts

MoveBullet:
    subq.l  #1,d1
    move.l  d1,Bullet
    move.l  y_pos,d2
    addq.l  #7,d2
    ;cmp    d1,d2
    ;beq    CheckHit
    cmp #0,d1
    beq Lose
    rts

get_key:
    tst.w   (doorsos::kb_vars+$1c)        ;is there a key?
    bne     keypressed                   ;if yes.. go to keypressed
    clr.w   d3                                    ;clear the old key
    rts

keypressed:
    move.w (doorsos::kb_vars+$1e),d3         ;move the key code into d3
    clr.w     (doorsos::kb_vars+$1c)               ;clear the keypress flag
    rts

exit_prgm:
    jsr graphlib::clr_scr
    move.w  #4,-(a7)
    pea mem(pc)
    move.w  #0,-(a7)
    move.w  #0,-(a7)
    jsr doorsos::DrawStrXY  
    lea 10(a7),a7
    jsr userlib::idle_loop
    bra IOH

Lose:
    jsr graphlib::clr_scr
    move.w  #4,-(a7)
    pea lost(pc)
    move.w  #0,-(a7)
    move.w  #0,-(a7)
    jsr doorsos::DrawStrXY  
    lea 10(a7),a7
    jsr userlib::idle_loop
    bra IOH

win:
    jsr graphlib::clr_scr
    move.w  #4,-(a7)
    pea won(pc)
    move.w  #0,-(a7)
    move.w  #0,-(a7)
    jsr doorsos::DrawStrXY  
    lea 10(a7),a7
    jsr userlib::idle_loop
    bra IOH

Fire:
    move.l  #87,Bullet
    rts

ClearBuffer:
    move.l  vid_addr,a0
    eor.l   d0,d0
    move.l  #959,d1

clear_buffer:
    move.l  d0,(a0)
    addq    #4,a0
    dbra    d1,clear_buffer
    rts

CopyBufferToScreen:
    move.l  vid_addr,a0
    lea doorsos::main_lcd,a1
    move.l  #3839,d1
    
copy_buffer:
    move.b  (a0),d0
    move.b  d0,(a1)
    addq    #1,a0
    addq    #1,a1
    dbra    d1,copy_buffer
    rts

PutSprite:
    move.l  vid_addr,a1
    mulu    #30,d1
    adda.l  d1,a1
    move.w  d0,d1
    lsr.w   #3,d1
    adda.l  d1,a1
    andi.l  #%111,d0
    moveq   #7,d2

draw_a_row:
    eor d1,d1
    move.b  (a0),d1
    ror.w   d0,d1
    or.b    d1,(a1)
    addq    #1,a1
    rol.w   #8,d1
    or.b    d1,(a1)
    adda.l  #29,a1
    addq    #1,a0
    dbra    d2,draw_a_row
    rts
    
IOH:
    move.w  vid_handle,-(a7)
    jsr doorsos::HeapFree
    addq.l  #2,a7
    rts

;strings
_comment:
    dc.b "Archer By Grant Elliott",0
won:
    dc.b "Congratulations",0
lost:
    dc.b "You Lost",0
mem:
    dc.b "Not Enough Memory",0

;variables
Temp:
    dc.w    0
Bullet:
    dc.w    88
y_pos:
    dc.l    0
x_pos:
    dc.l    0
vid_addr:
    dc.l    0
vid_handle:
    dc.w    0



;sprites
target:
    dc.b    %11111111
    dc.b    %10000001
    dc.b    %10011001
    dc.b    %10111101
    dc.b    %10111101
    dc.b    %10011001
    dc.b    %10000001
    dc.b    %11111111

shot:   
    dc.b    %00011000
    dc.b    %00111100
    dc.b    %00111100
    dc.b    %00111100
    dc.b    %00111100
    dc.b    %00111100
    dc.b    %00111100
    dc.b    %00111100

    end