LZ: Here is the prog., what is the prob.?


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

LZ: Here is the prog., what is the prob.?



Here is the prog. I have been working on and can't get NASR to work. Note
this is a snipit of the whole code but it should work just fine.  THere is
something I'm doing wrong with NASR I just can't figure out. Can anybody
help me....please?  :|

Also, this prog. worked just fine before I implimented nasr so my other
graphical stuff should be fine. Don't worry about that. Just the
background routine taht calls nasr and get sprites drawn, well actually,
it doesn't, it screws up the calc.


********************************************************************


; _____________________________________________________________________
;|                                                                     |
;|                                   ** ** ***                         |
;|  MMMM    MMMM                        * *** *                        |
;|  MMMMM  MMMMM   EE   GGGG   AAAA      * **                          |
;|  MM MM  MM MM  E    G      A    A      **                           |
;|  MM  MMMM  MM  EEE  G  GG  AAAAAA     * *    _________              |
;|  MM   MM   MM  E    G   G  A    A     **   __ _\_______\_           |
;|  MM   MM   MM   EE   GGG   A    A     **  /  \           \-\-\____  |
;|                                        * | () |_______________/ \_\ |
;|  RRRRRR                                   \__/                \_/   |
;|  RR   RR    AAAA    CCCC   EE  RRRR                                 |
;|  RRRRRR    A    A  C      E    R   R      Mega Racer (c.)           |
;|  RR  RR    AAAAAA  C      EEE  RRRR       Will Stokes               |
;|  RR   RR   A    A  C      E    R   R      Version 1.01              |
;|  RR    RR  A    A   CCCC   EE  R   R      December 1996             |
;|                                                                     |
;|_____________________________________________________________________|
;|                                                                     |
;| Will Stokes               wstokes@vertex.ucls.uchicago.edu          |
;|                                                                     |
;| My Personal Homepage:     http://www.uic.edu/~hhstokes/will.htm     |
;|                                                                     |
;|   My Calculator Website:     http://www.uic.edu/~hhstokes/          |
;|(The TI-85 Calculator Center)                                        |
;|_____________________________________________________________________|




;  ___________________________________________________________
; /                                                           \
;|  BASIC STUFF YOU HAVE TO DO TO SETUP FILE/GAME STRUCTURE    |
; \___________________________________________________________/





#include "TI-85.H"              ;\_____Setup
.org 0                          ;/     Stuff
.db "Mega Racer Version 1.01", 0  ;<-----Name that appears in ZShell
menu.



;  ___________________________________________________
; /                                                   \
;|  Set Variables and discribe what they are used for  |
; \___________________________________________________/



HX = TEXT_MEM             ; x value of point on horizen
I = TEXT_MEM+3            ; value used to draw road outline
endgame = TEXT_MEM+5      ;check bit for quiting sequence.
endgame2 = TEXT_MEM+6      ;check bit for quiting sequence.

arg1 = TEXT_MEM+7   ;\
arg2 = TEXT_MEM+8   ; )---used in math routin

















        sub b
        SRL A
        ld b, a
        ld a, (HX)
        add a, b
        ld (temp2), a
        ld l, a
        ld a, (I)
        ld h, a
        CALL_(Line)
        ld a, (temp2)
        ld e, a
        ld a, (I)
        ld d, a
        ld a, (HX)
        ld l, a
        ld a, 42
        ld h, a
        CALL_(Line)
        ret   ; Return to basic game stem after road has been drawn.


drd2:          ; routine that actually draws the road.

        ld a, (HX)
        cp 86
        CALL_NC(d3)
        ld a, (HX)
        cp 86
        CALL_C(d4)
        ret

d3:
        ld a, 0
        ld d, a
        ld a, 86
        ld e, a
        ld b, a
        ld a, (HX)
        sub b
        SRL A
        ld b, a
        ld a, 86
        add a, b
        ld (temp2), a
        ld l, a
        ld a, (I)
        ld h, a
        CALL_(Line)
        ld a, 42
        ld h, a
        ld a, (HX)
        ld l, a
        ld a, (temp2)
        ld e, a
        ld a, (I)
        ld d, a
        CALL_(Line)
        ret

d4:
        ld a, 0
        ld d, a
        ld a, 86
        ld e, a
        ld a, (HX)
        ld b, a
        ld a, e
        sub b
        SRL A
        ld b, a
        ld a, (HX)
        add a, b
        ld (temp2), a
        ld l, a
        ld a, (I)
        ld h, a
        CALL_(Line)
        ld a, (temp2)
        ld e, a
        ld a, (I)
        ld d, a
        ld a, (HX)
        ld l, a
        ld a, 42
        ld h, a
        CALL_(Line)
        ret   ; Return to basic game stem after road has been drawn.

l3:
        ld d, 42
        ld e, 0
        ld h, 42
        ld l, 126
        CALL_(Line)

        ret   ; Return to basic game stem after road has been drawn.


;          Optimized Implementation of Bresenham's line algorithm
;         by Stephane JANTZEN (Stephane.Jantzen@scinfo.u-nancy.fr)


Line:

        ld      A,D
        sub     H
        jr      NC,DXPositive    ;delta_x > 0
DXNegative:
        neg
DXPositive:
        ld      B,A              ;B <- |delta_x|
        ld      A,E
        sub     L
        jr      NC,DYPositive    ;delta_y > 0
DYNegative:
        neg
DYPositive:
        sub     B               ;|delta_y|
        push    AF
        jr      C,DeltaX        ;|delta_x| > |delta_y|
DeltaY:
        ld      A,H             ;if |delta_x| < |delta_y| then
        ld      H,L             ;then values x and y are swapped
        ld      L,A             ;so the loop will always be performed on the
        ld      A,D             ;x value. A flag must be set to
        ld      D,E             ;remind that data must be drawn (y,x)
        ld      E,A             ;instead of (x,y)

        ;ld      A,$01
        ;ld      (Flag),A        ;the Flag !!!
DeltaX:
        ld      A,D
        sub     H
        jr      NC,TestDY        ;x1 < x2
TestDX:
        ex	DE,HL
TestDY:
        ld      A,E
        sub     L
        ld      A,$01
        jr      NC,StoreA
        neg                     ;y1 > y2 : in case2 the 'y' variable
StoreA:
        ld      (Way),A
InitLine:
        ld      B,H
        ld      C,L
        ld      A,E
        sub     L
        jr      NC,EndInit
        ld      A,L
        ld      L,E
        ld      E,A
EndInit:
        ld      A,E
        sub     L
        rla
        ld      L,A             ;value to add in case1 (d < 0)
        add     A,H
        sub     D
        ld      E,A             ;'d' variable is initialised
        add     A,H
        sub     D
        ld      H,A             ;value to add in case2 (d >= 0)
Loop:
        ld      A,B
        sub     D
        jr      NC,EndLine       ;the line is completely drawn.
        pop     AF
        ;ld      A,(Flag)
        bit     7,A
        push    AF
        push    AF
        push    BC
        jr      Z,DrawPoint
        ld      A,B
        ld      B,C
        ld      C,A
DrawPoint:
        CALL_(PointOn)
        pop     BC
        pop     AF
TestD:
        bit     7,E
        jr      NZ,Case1
Case2:                          ;d >= 0
        ld      A,E
        add     A,H
        ld      E,A
        ld      A,(Way)
        add     A,C
        ld      C,A
        jr      EndLoop
Case1:                          ;d < 0
        ld      A,E
        add     A,L
        ld      E,A
EndLoop:
        inc     B
        jr      Loop
EndLine:
        pop     AF              ;MUST NOT BE REMOVED
        ret

PointOn:
        push    DE              ;MUST NOT BE REMOVED
        push    HL              ;MUST NOT BE REMOVED
        ROM_CALL(FIND_PIXEL)
        ld      DE,$FC00
        add     HL,DE
        or      (HL)
        ld      (HL),A
        pop     HL              ;MUST NOT BE REMOVED
        pop     DE              ;MUST NOT BE REMOVED
        ret







SetPixel:

        ld a, (ty)
        cp 1
        jr z, Pon
        jr Poff

Pon:
 ROM_CALL(FIND_PIXEL)
 ld de,VIDEO_MEM
 add hl,de
 or (hl)
 ld (hl),a
 ret

Poff:
 ROM_CALL(FIND_PIXEL)
 ld de,VIDEO_MEM
 add hl,de
 xor 255
 and (hl)
 ld (hl),a
 ret
ChangePixel:
        ROM_CALL(FIND_PIXEL)
        ld de, $FC00
        add hl, de
        xor (hl)
        ld (hl), a
        ret

;***********************************************
;       NASR WARP - by Jingyang Xu             *
;   (br00416@bingsuns.cc.binghamton.edu)       *
; Include this header if you wish to use       *
;       the subroutines please                 *
;***********************************************
;
;If you have a sprite that is x wide and y high then:
;
;a=smallest integer greater than or equal to x/8
;b=a*8-x+1
;c=y
;
;Define a sprite like this:
;
;Sprite:
;       .db     a,b,c  <- 3 bytes
;       .db     %xxxxxxxx,%xxxxxxxx,%xxxxxxxx,... <- first line of
;sprite
;       .db     %xxxxxxxx,%xxxxxxxx,%xxxxxxxx,... <- 2nd line
;       .db     ....                              <- other lines like
;above
;
;Each of the x's is a 1 or a 0, depending on if )
        ld d, a
        ld a, (HX)
        ld l, a
        ld a, 42
        ld h, a
        CALL_(Line)
        ret   ; Return to basic game stem after road has been drawn.

l3:
        ld d, 42
        ld e, 0
        ld h, 42
        ld l, 126
        CALL_(Line)

        ret   ; Return to basic game stem after road has been drawn.


;          Optimized Implementation of Bresenham's line algorithm
;         by Stephane JANTZEN (Stephane.Jantzen@scinfo.u-nancy.fr)


Line:

        ld      A,D
        sub     H
        jr      NC,DXPositive    ;delta_x > 0
DXNegative:
        neg
DXPositive:
        ld      B,A              ;B <- |delta_x|
        ld      A,E
        sub     L
        jr      NC,DYPositive    ;delta_y > 0
DYNegative:
        neg
DYPositive:
        sub     B               ;|delta_y|
        push    AF
        jr      C,DeltaX        ;|delta_x| > |delta_y|
DeltaY:
        ld      A,H             ;if |delta_x| < |delta_y| then
        ld      H,L             ;then values x and y are swapped
        ld      L,A             ;so the loop will always be performed on the
        ld      A,D             ;x value. A flag must be set to
        ld      D,E             ;remind that data must be drawn (y,x)
        ld      E,A             ;instead of (x,y)

        ;ld      A,$01
        ;ld      (Flag),A        ;the Flag !!!
DeltaX:
        ld      A,D
        sub     H
        jr      NC,TestDY        ;x1 < x2
TestDX:
        ex	DE,HL
TestDY:
        ld      A,E
        sub     L
        ld      A,$01
        jr      NC,StoreA
        neg                     ;y1 > y2 : in case2 the 'y' variable
StoreA:
        ld      (Way),A
InitLine:
        ld      B,H
        ld      C,L
        ld      A,E
        sub     L
        jr      NC,EndInit
        ld      A,L
        ld      L,E
        ld      E,A
EndInit:
        ld      A,E
        sub     L
        rla
        ld      L,A             ;value to add in case1 (d < 0)
        add     A,H
        sub     D
        ld      E,A             ;'d' variable is initialised
        add     A,H
        sub     D
        ld      H,A             ;value to add in case2 (d >= 0)
Loop:
        ld      A,B
        sub     D
        jr      NC,EndLine       ;the line is completely drawn.
        pop     AF
        ;ld      A,(Flag)
        bit     7,A
        push    AF
        push    AF
        push    BC
        jr      Z,DrawPoint
        ld      A,B
        ld      B,C
        ld      C,A
DrawPoint:
        CALL_(PointOn)
        pop     BC
        pop     AF
TestD:
        bit     7,E
        jr      NZ,Case1
Case2:                          ;d >= 0
        ld      A,E
        add     A,H
        ld      E,A
        ld      A,(Way)
        add     A,C
        ld      C,A
        jr      EndLoop
Case1:                          ;d < 0
        ld      A,E
        add     A,L
        ld      E,A
EndLoop:
        inc     B
        jr      Loop
EndLine:
        pop     AF              ;MUST NOT BE REMOVED
        ret

PointOn:
        push    DE              ;MUST NOT BE REMOVED
        push    HL              ;MUST
        cp      0
        jr      z,skipshift
SpriLoop1:
        ld      a,b
        ld      HL,TempLine
        ld      b,e
        scf
SpriLoop2:
        rr      (HL)
        inc     HL
        djnz    SpriLoop2
        ld      b,a
        djnz    SpriLoop1
        ld      b,d
skipshift:
        ld      a,$ff           ;fill accumulator
        inc     b
mask1:
        srl     a               ;make the mask
        djnz    mask1           ;something like
        scf                     ;00001111 ->
        rl      a
        ld      hl,(PicCoor)    ;implement the mask
        or      (hl)            ;this preserve the 0 bits
        ld      hl,TempLine   ;become xxxx1111
        and     (hl)            ;when anded, become
        ld      (hl),a          ;xxxxyyyy
        ld      b,d             ;retrieve b
        ld      a,(offset)
        dec     a
        sub     b
        jr      nc,skip
        sub     248
skip:
        ld      b,a
        inc     b
        ld      a,$ff
mask2:
        sla     a
        djnz    mask2
        scf
        rr      a
        dec     e
        ld      hl,(PicCoor)
        ld      d,0
        add     hl,de
        or      (hl)
        ld      hl,TempLine
        add     hl,de
        and     (hl)
        ld      (hl),a
        inc     e
        ld      c,e
        ld      hl,(PicCoor)
        ld      de,16
        push    hl
        add     hl,de
        ld      (PicCoor),hl
        pop     hl
        ld      de,TempLine
        ex      de,hl
        ld      b,0
        ldir
        pop     de
        pop     bc
        pop     hl
        dec     d
        jp      nz,YLoop
        pop     bc
        ret

;**************************************************8




b1:
        .dw 997
b2:
        .dw 998
b3:
        .dw 999

Mtn1:
        .db     4,1,20
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00110000, %00000000
        .db     %00000000, %00000000, %01111000, %00000000
        .db     %00000000, %01000000, %11111100, %00000000
        .db     %00000000, %11100001, %11111110, %00000000
        .db     %00000001, %11111111, %11111111, %00000100
        .db     %00000011, %11111111, %11111111, %10001110
        .db     %00000011, %11111111, %11111111, %11011111
        .db     %00100111, %11111111, %11111111, %11111111
        .db     %01110111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111

Mtn2:
        .db     4,1,20
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000001
        .db     %00000000, %00000000, %00000000, %00001011
        .db     %00000000, %00000000, %00000000, %00011111
        .db     %00000000, %00000000, %00000000, %00111111
        .db     %00000000, %00000000, %00000001, %01111111
        .db     %00000000, %00000000, %00000011, %11111111
        .db     %00000010, %00000000, %00000111, %11111111
        .db     %10000111, %00000000, %00101111, %11111111
        .db     %11001111, %10000100, %01111111, %11111111
        .db     %11111111, %11001110, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111

Mtn3:
        .db     4,1,20
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %10100000, %00000000, %00000000, %00001000
        .db     %11110010, %00000000, %00000001, %00011100
        .db     %11111011, %00010000, %00001011, %10111110
        .db     %11111011, %10111000, %00011111, %11111111
        .db     %11111111, %11111101, %01111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111

Mtn4:
        .db     4,2,20
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %00000000, %00000000, %00000000, %00000000
        .db     %10100000, %00000000, %00000000, %00000000
        .db     %11110000, %00000000, %00000000, %00000000
        .db     %11111010, %00000000, %00000000, %00000000
        .db     %11111111, %00000000, %00000000, %00101000
        .db     %11111111, %00000000, %00000000, %01111100
        .db     %11111111, %10100000, %00000000, %11111110
        .db     %11111111, %11110000, %00000001, %11111111
        .db     %11111111, %11111000, %00000011, %11111111
        .db     %11111111, %11111101, %00010111, %11111111
        .db     %11111111, %11111111, %10111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111
        .db     %11111111, %11111111, %11111111, %11111111


.end