Re: A89: Another easy one
[Prev][Next][Index][Thread]
Re: A89: Another easy one
Ok, I fixed the 1111 error (I don't know why, but it stopped.) Now, I've got
a different problem. I can't seem to read keys. I've tried a few different
methods; I can't get any to work. Here's the source as it is now. The
problems: It fires immediately when I start the prgm, after I press a key on
the "You Lost" screen, it returns to moving the target, when the target
reaches the bottom, the "You lost" screen freezes, and I get address errors
and illegal instructions periodically. I must be doing something really,
really wrong... Please help me!
;libraries
include "doorsos.h"
include "userlib.h"
include "graphlib.h"
;definitions
xdef _main
xdef _comment
xdef _ti89
;main program
_main:
move.l $300000,d0
cmp.l #$4E56FFCC,d0
beq v1_00_rom
cmp.l #$77044EB9,d0
beq v1_05_rom
bra other_rom
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
v1_00_rom:
move.b #$00,d0
bra found_rom
v1_05_rom:
move.b #$01,d0
bra found_rom
other_rom:
bra err
found_rom
move.b d0,rom_ver
bra Go
err:
jsr graphlib::clr_scr
move.w #4,-(a7)
pea rom(pc)
move.w #0,-(a7)
move.w #0,-(a7)
jsr doorsos::DrawStrXY
lea 10(a7),a7
jsr userlib::idle_loop
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 Checkkeys
bra anim_sprite
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
move.l #0,x_pos
cmp #88,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:
move.b rom_ver,d0
cmp.b #$00,d0
beq v1_00_key
cmp #13,d0
beq Fire
rts
v1_05_key:
eor.w d0,d0
tst.w doorsos::kb_vars+$1c+4
beq done_check
move.w doorsos::kb_vars+$1e+4,d0
clr.w doorsos::kb_vars+$1c+4
bsr done_check
rts
v1_00_key
eor.w d0,d0
tst.w doorsos::kb_vars+$1c
beq done_check
move.w doorsos::kb_vars+$1e,d0
clr.w doorsos::kb_vars+$1c
bsr done_check
rts
done_check
rts
Fire:
move.l #87,Bullet
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
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
rom:
dc.b "Invalid Rom",0
;variables
rom_ver:
dc.b 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
Grant Elliott
<A
HREF="http://www.crosswinds.net/~proganon">Programmers Anonymous</A>
Follow-Ups: