A86: Problems


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

A86: Problems




Houston, we've got a problem. 

I am trying to convert a cheap 85 game that I wrote a while back to 86
ASM(this prog was my first attempt at ASM), and when I compiled it on the
86(after changing the .org, and getting rid of the .db "description"), it
compiled Okay. But when it ran, it was a disaster.  My being unfamiliar
with the 86, I was wondering if any of you could take a look at the code
below. It is supposed to be a character-animation(hah!) xwing-vs-tie
fighter game, but I never got around to putting in the tie. Thanx.

--JdAoMtEyS
-----------------------------
"Oh my god, they killed Kenny!"

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


.org _asm_exec_ram



        call _clrLCD



xx = TEXT_MEM                    ;assign constants so I don't have to
remember
xy = TEXT_MEM+1                ;memory addresses. Then, set both to 0.   
                                                                
tie_x = TEXT_MEM+2
tie_y = TEXT_MEM+3
direction = TEXT_MEM+4

        ld      a,0
        ld      (xx),a
        ld      (xy),a
        ld      a,2
        ld      (direction),a

Top_of_Program:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      9
        call    z,&y_high
        ld      (xy),a
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (xx),a
        ld      (_penCol),a
        ld      hl,&xwing_char          ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
                                        ;Displays whatever is in reg.
pair hl

        ld      a,(direction)           ;Draw the gun.
        cp      0
        ld      a,(direction)           ;Draw the gun.
        call    z,&gun_n
        ld      a,(direction)           ;Draw the gun.
        cp      1
        call    z,&gun_ne
        ld      a,(direction)           ;Draw the gun.
        cp      2
        call    z,&gun_e
        ld      a,(direction)           ;Draw the gun.
        cp      3
        call    z,&gun_se
        ld      a,(direction)           ;Draw the gun.
        cp      4
        call    z,&gun_s
        ld      a,(direction)           ;Draw the gun.
        cp      5
        call    z,&gun_sw
        ld      a,(direction)           ;Draw the gun.
        cp      6
        call    z,&gun_w
        ld      a,(direction)           ;Draw the gun.
        cp      7
        call    z,&gun_nw


get_key_Loop:                           ;Get key, and then compare to key
codes
        call    GET_KEY
        cp      1
        jp      z,&Down
        cp      3
        jp      z,&Right
        cp      4
        jp      z,&Up
        cp      2
        jp      z,&Left 
        cp      55
        jp      z,&Exit
        cp      50
        jr      z,dir_left
        cp      49
        jr      z,dir_right        
        jr      get_key_Loop

dir_left:
        call    &clear_gun
        ld      a,(direction)
        dec     a
        ld      (direction),a
        cp      -1
        call    z,&dir_low
        jp      &Top_of_Program
dir_right:
        call    &clear_gun
        ld      a,(direction)
        inc     a
        ld      (direction),a
        cp      8
        call    z,&dir_high
        jp      &Top_of_Program
dir_high:
        ld      a,0
        ld      (direction),a
        ret
dir_low:
        ld      a,7
        ld      (direction),a
        ret

gun_n:

        ld      a,(xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        ld      (_penCol),a
        ld      hl,&up_down
        call    _puts
        ret
gun_s:
        ld      a,(xy)
        inc     a
        cp      8                       ;bounds checking on Y axis
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        ld      (_penCol),a
        ld      hl,&up_down
        call    _puts
        ret
gun_e:
        ld      a,(xx)
        inc     a
        cp      20                      ;bounds checking on Y axis
        call    z,&x_high
        ld      (_penCol),a          ;set Y axis
        ld      a,(xy)
        ld      (_penRow),a
        ld      hl,&left_right
        call    _puts
        ret

gun_w:
        ld      a,(xx)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&x_low
        ld      (_penCol),a          ;set Y axis
        ld      a,(xy)
        ld      (_penRow),a
        ld      hl,&left_right
        call    _puts
        ret
gun_ne:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        inc     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&ne_sw               ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret
gun_sw:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        inc     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        dec     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&ne_sw               ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret
gun_nw:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        dec     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&nw_se               ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret

gun_se:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        inc     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        inc     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&nw_se               ;assign 'X' to hl register
        call    _puts
        ret
gun_nq:
        ld      a,(xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        ld      (_penCol),a
        ld      hl,&blank_char
        call    _puts
        ret
gun_sq:
        ld      a,(xy)
        inc     a
        cp      8                       ;bounds checking on Y axis
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        ld      (_penCol),a
        ld      hl,&blank_char
        call    _puts
        ret
gun_eq:
        ld      a,(xx)
        inc     a
        cp      20                      ;bounds checking on Y axis
        call    z,&x_high
        ld      (_penCol),a          ;set Y axis
        ld      a,(xy)
        ld      (_penRow),a
        ld      hl,&blank_char
        call    _puts
        ret

gun_wq:
        ld      a,(xx)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&x_low
        ld      (_penCol),a          ;set Y axis
        ld      a,(xy)
        ld      (_penRow),a
        ld      hl,&blank_char
        call    _puts
        ret
gun_neq:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        inc     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&blank_char          ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret
gun_swq:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        inc     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        dec     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&blank_char          ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret
gun_nwq:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        dec     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        dec     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&blank_char          ;assign 'X' to hl register
        call    _puts                ;"Display Zero Terminated String".
        ret

gun_seq:
        ld      a,(xy)                  ;display 'X' at (xx,xy)
        inc     a
        cp      -1                      ;bounds checking on Y axis
        call    z,&y_low
        cp      8
        call    z,&y_high
        ld      (_penRow),a          ;set Y axis
        ld      a,(xx)
        inc     a
        cp      -1
        call    z,&x_low
        cp      20
        call    z,&x_high
        ld      (_penCol),a
        ld      hl,&blank_char          ;assign 'X' to hl register
        call    _puts
        ret

x_low:
        ld      a,19
        ret
x_high:
        ld      a,0

        ret
y_low:
        ld      a,7

        ret

y_high:
        ld      a,0

        ret

clear_gun:
        ld      a,(direction)          
        cp      0
        call    z,&gun_nq
        ld      a,(direction)          
        cp      1
        call    z,&gun_neq
        ld      a,(direction)          
        cp      2
        call    z,&gun_eq
        ld      a,(direction)          
        cp      3
        call    z,&gun_seq
        ld      a,(direction)          
        cp      4
        call    z,&gun_sq
        ld      a,(direction)          
        cp      5
        call    z,&gun_swq
        ld      a,(direction)          
        cp      6
        call    z,&gun_wq
        ld      a,(direction)          
        cp      7
        call    z,&gun_nwq
        ret

clear_xwing:
        ld      a,(xy)                 
        ld      (_penRow),a
        ld      a,(xx)
        ld      (_penCol),a
        ld      hl,&blank_char
        call    _puts
        ret
Left:
        call    &clear_gun        
        call    &clear_xwing
        ld      a,(xx)                  ;then update position
        dec     a
        ld      (xx),a
        jp      &Top_of_Program         ;go to top so redraws, and then
gets key

Up:
        call    &clear_gun
        call    &clear_xwing
        ld      a,(xy)
        dec     a
        ld      (xy),a
        jp      &Top_of_Program

Right:
        call    &clear_gun
        call    &clear_xwing
        ld      a,(xx)
        inc     a
        ld      (xx),a
        jp      &Top_of_Program

Down:
        call    &clear_gun
        call    &clear_xwing
        ld      a,(xy)
        inc     a
        ld      (xy),a
        jp      &Top_of_Program
                                        
Exit:
        ret
xwing_char:                             ;assign characters. For use
earlier in prog.
        .db     'X',0

blank_char:
        .db     ' ',0

up_down:
        .db     '|',0
left_right:
        .db     '-',0
ne_sw:
        .db     '/',0
nw_se:
        .db     '\',0
tie:
        .db     '—',0


.end










_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]