A89: Another easy one


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

A89: Another easy one



This is the first asm game I've written, and I'm stuck.  It assembles fine, 
but when I run it on the emulator, I get a "Line 1111 Emulator" error.  I 
can't put it on my calculator because my link port is broken.  I'm sure it 
doesn't work anyway, but why can't I even get it to crash and/or freeze 
and/or work?  Thanks.

                                                Grant Elliott
                                                <A 
HREF="http://www.crosswinds.net/~proganon">Programmers Anonymous</A> 

The source:

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

;definitions
    xdef    _main
    xdef    _comment
    xdef    _ti89
doorsos::GKeyIn equ _ROM_CALL_17E

;main program
_main:
    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  #92,Bullet
    bsr anim_sprite
    move.w  vid_handle,-(a7)
    jsr doorsos::HeapFree
    addq.l  #2,a7
    eor d0,d0
    eor d1,d1
    move.l  d0,y_pos
    move.l  d0,x_pos
    rts

;subroutines
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 #92,Bullet
    beq Checkkeys
    rts

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
    cmp #92,d1
    beq Lose
    rts

UpdateBullet:
    move.l  Bullet,d1
    cmp #92,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

CheckHit:
    cmp #76,x_pos
    ble Checkhitb
    rts

Checkhitb:
    cmp #76,x_pos
    bge win
    rts

Checkkeys:
    jsr doorsos::GKeyIn
    cmp     #13,d0
    beq Fire
    rts

Fire:
    move.l  #91,Bullet
    rts

exit_prgm:
    move.w  #4,-(a7)
    lea mem(pc),a0
    move.l  a0,-(a7)
    move.w  #0,-(a7)
    move.w  #10,(a7)
    jsr graphlib::clr_scr
    jsr doorsos::DrawStrXY
    add.l   #10,a7
    rts

Lose:
    move.w  #4,-(a7)
    lea lost(pc),a0
    move.l  a0,-(a7)
    move.w  #0,-(a7)
    move.w  #30,(a7)
    jsr graphlib::clr_scr
    jsr doorsos::DrawStrXY
    add.l   #10,a7
    rts

win:
    move.w  #4,-(a7)
    lea won(pc),a0
    move.l  a0,-(a7)
    move.w  #0,-(a7)
    move.w  #20,(a7)
    jsr graphlib::clr_scr
    jsr doorsos::DrawStrXY
    add.l   #10,a7
    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
    
;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
useless:
    dc.b    0
Bullet:
    dc.w    92
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

Arch26.ZIP


Follow-Ups: