This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 20 Feb 2009 11:44:13 pm    Post subject:

NOTE: I have solved the problem mentioned in this post. My most recent problem is listed in my fourth posting starting with "Sure enough, it was putAndSprite....".

Recently I have been growing in my proficiency with the z80 programming tasks and methods. Upon gradually increasing the complexity of my programs, I decided to make a simple program to make a sprite move around on screen. Bam! Done! Next, having tackled that, I decided to make the sprite shoot projectiles or bullets, as in Phoenix or Galaxian. Then my problem revealed itself: I made the program just fine. I double checked, triple checked, heck, whatever 20-check is. However, when I compile it, the 'call' and 'ret' functions do not seem to work properly...I attempted switching from Ion shell to Mirage shell, but...to no avail. So now, I'm hoping that someone may be able to help me through this post. (By the way, I'm running on Windows Vista home Premium Edition...if that makes any difference.)
Also, what's interesting is that jumps within the code work fine...meaning that there's nothing wrong with pc. Maybe something I overlooked with the stack?

For my compiling, I used Andys Assembler Compiler package from ticalc.org.
Here's the link:
http://www.ticalc.org/archives/files/fileinfo/179/17967.html

This is only the movement aspect of the sprite code, but it still doesn't compile:

Code:
 #include "ti83plus.inc"
#include "mirage.inc"
#include "keys.inc"
   .org   $9d93
   .db   $BB,$6D
   ret
   .db   1
   .db   %00000000,%00000000
   .db   %00011000,%10000100
   .db   %00011000,%11000100
   .db   %00011000,%11100100
   .db   %00011000,%11010100
   .db   %00011000,%11001100                      ;My initials :D
   .db   %00011000,%11001100
   .db   %00011000,%11001100
   .db   %10010000,%11001100
   .db   %01100000,%11001100
   .db   %00000000,%00000000
   .db   %01010101,%01010101
   .db   %10101010,%10101010
   .db   %00000000,%00000000
   .db   %00000000,%00000000
   .db   "Moving Sprite",0

x = saferam1+0                                       ;Disregard the variables
y = saferam1+2                                       ;The ones not shown in this code are
xbul = saferam1+4                                   ;used in a second part to this program,
temp1 = saferam1+6                                ;which happens to be the bullet section :)
jump = saferam1+8

main:
   DI
   bcall(_clrlcdfull)
   bcall(_bufclr)
   ld a,40
   ld (x),a
   ld a,30
   ld (y),a
   call display

mainloop:   
   ld a,group1
   out (1),a
   in a,(1)
   bit 6,a
   jp z,exit                               ;'exit:' is defined later on. All it does is ret.
   call move
   jr mainloop

;-----------------------------
;>>Player Ship Movement Code<<
;-----------------------------
move:   
   ld a,group0      ;
   out (1),a                   ;
   in a,(1)                     ;determine if arrow
   ld b,4         ;keys were pressed
movl:   rra         ;
   jr c,aropres      ;
   djnz movl                     ;
   ret         ;else: return
aropres:
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,9
   ld ix,ship
   call isprite                              ;erase sprite from plotsscreen
   in a,(1)
   ld b,a
   bit 0,b
   jr nz,nodown
   ld a,(y)
   cp 60
   jr z,nodown
   inc a
   ld (y),a
nodown:   bit 3,b
   jr nz,noup
   ld a,(y)
   cp 0
   jr z,noup
   dec a
   ld (y),a
noup:   bit 1,b
   jr nz,noleft
   ld a,(x)
   cp 0
   jr z,noleft
   dec a
   ld (x),a
noleft:   bit 2,b
   jr nz,norght
   ld a,(x)
   cp 88
   jr z,norght
   inc a
   ld (x),a
norght: jr display                       ;ya, ya, ya. Not needed.

display:
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,9
   ld ix,ship
   call isprite                  ;copy the sprite to plotsscreen
   call ifastcopy              ;copy graphbuffer to lcd screen...FAST! haha
   ret


ship:
   .db %00000000
   .db %00000000
   .db %00011000
   .db %00111100
   .db %00111100
   .db %10111101
   .db %10111101
   .db %11111111
   .db %11111111


Maybe my computer is partially retarded and doesn't compile right?? I don't know.
Any help is greatly appreciated, though!!
Thanks ahead of time!


Last edited by Guest on 24 Mar 2009 06:58:43 pm; edited 1 time in total
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 21 Feb 2009 11:40:20 am    Post subject:

What error are you getting?
I copied the code and it seems to work fine.
I did define group0 = %11111110, maybe that's what you're missing?
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 22 Feb 2009 02:52:31 am    Post subject:

Really..? Ya, I have the group0 defined in my keys.inc file. Oh, and there's actually a mistype that I just realized. I can fully 'compile' the program, but when I run it on my emulator (Tilem), the error presents itself. When I said "error with compiling", I was meaning that there may be something wrong with the compiler. Not sure though. It may be an issue with Vista..

Three quick questions to help me out, though:
1) Are you running Windows Vista?
2) Are you actually running the program? or just compiling?
3) If you run the program on your computer, what emulator are you using?

Thanks again for taking time to help me out. I really appreciate it!
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 22 Feb 2009 03:46:08 pm    Post subject:

1. Yes, though it doesn't matter
2. Yes, compiling and running works (MOS)
3. I'm emulating it in PindurTI (fairly accurate to the hardware except for a few areas you're not using)

I've never heard of the compiler you're using, but I know that Brass works fine (one I use), TASM works fine (though is extremely out of date), and SPASM works fine.

Oh, incidentally, I did make another change:
for exit, I used call quittoshell instead of ret (only works with MOS)


Last edited by Guest on 11 Jul 2010 05:58:25 pm; edited 1 time in total
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 19 Mar 2009 10:14:36 pm    Post subject:

Hey, thanks for your help. After fiddling around with changing my program header to Ion, and getting a different compiler, I got the program to work again. I appreciate the help! However, now, I've run into an actual issue within my program, and am eager to get it solved. I'm sure you've heard of the game Galaxian for the Atari (a great game, by the way!), and I'm also sure that you've heard of the game Phoenix for the TI-calcs, programmed by Patrick Davis. Well, I'm making a game similar to those two, and have hit a road block in the section of code which handles the on screen explosions. The issue is as follows:

Whenever a bullet makes contact with the player ship, certain bits are set to indicate that an explosion is going on (looking at the program may help to understand). Regardless, whenever a bullet makes contact and an explosion is initiated, a mere blank space is displayed, which is obviously not the kind of explosion I want. Wanting to get on with the programming, I'm open to any suggestions or solutions you or any fellow programmer may present. Thanks ahead of time!

NOTE: The code pertaining mainly to explosions is displayed in red.

Code:

.nolist
#include "ion.inc"
#include "keys.inc"
.list

x = saferam1+0
y = saferam1+2
xbul = saferam1+4
exbul = saferam1+6
bulpress = saferam1+8
return = saferam1+10
timer = saferam1+12
temp1 = saferam1+14

saveflag = saferam2+150
savepcoord = saferam2+152
savepbullets = saferam2+155

#ifdef TI83P
      .org  progstart-2
      .db   $BB,$6D
#else
     .org  progstart
#endif
     ret
     jr    nc,start
      .db   "~By Justin Niles",0

start:
   DI
   bcall(_clrlcdfull)
   bcall(_cleargbuf)
   ld a,40
   ld (x),a
   ld a,30
   ld (y),a
   call loadgmecode
   call movebullets
   ld a,0
   ld (return),a
   ld a,0
   ld (bulpress),a
   ld a,0
   ld (timer),a
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   call ionFastCopy

mainloop:
   ld a,group1
   out (1),a
   in a,(1)
   bit 6,a
   jp z,gameexit
   call handleexplosions
   call move
   call firebullets
   call movebullets
   call enemybullets
   call moveebullets
   call ionFastCopy
   jr mainloop
[color=red]
;----------------------
;>>>>Explosion Code<<<<
;----------------------
handleexplosions:
   ld hl,explosiondata  ;there are 15 current elements in 'explosiondata', broken up into groups of 3.
                                             ;The first number of a group of 3 is the status of the explosion
                                             ;the second number represents the explosion's x-coordinates
                                             ;the third number represents the explosion's y-coordinates
   ld b,5
exfloop:
   ld a,(hl)
   or a                        ;check if (hl)=0
   push hl
   push bc                   ;preserve hl and bc
   call nz,doexplosion   ;if (hl)/=0, then goto doexplosion
   pop bc
   pop hl                     ;restore hl and bc
   inc hl
   inc hl
   inc hl                      ;increment hl to the next group of 3 elements
   djnz exfloop
   ret                         ;return when finished
doexplosion:
   ld b,a                      ;save a (which holds the data in (hl))
   inc (hl)
   sub 6                     ;subtract 6 from a
   jr nz,skipover1
   ld (hl),0                 ;if a=0, load into (hl),0
skipover1:
   ld a,b                    ;restore a
   add a,b
   add a,b
   add a,b
   add a,b
   add a,b
   add a,b
   add a,b
   add a,b                  ;multiply a times 9
   sub 9                    ;subtract 9 from a
   ld d,0
   ld e,a                    ;ld de,a
   ld ix,explosionimage    ;scroll towards the bottom to see the image(s)
   add ix,de               ;essientially adding ix and a
   inc hl
   ld d,(hl)                 ;ld x-coord into d
   inc hl
   ld a,(hl)
   ld l,a                     ;ld y-coord into l
   ld a,d                    ;ld d (which contains x-coord) into a
   ld b,8
   call putSpriteAnd    ;ionPutSprite, using AND logic
   ret
[/color]
;-----------------------------
;>>Player Ship Movement Code<<
;-----------------------------
move:
   ld a,group0      ;
   out (1),a      ;
   in a,(1)      ;determine if arrow
   ld b,4         ;keys were pressed
movl:   rra         ;
   jr c,aropres      ;
   djnz movl      ;
   ret         ;else: return
aropres:
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   in a,(1)
   ld b,a
   bit 0,b
   jr nz,nodown
   ld a,(y)
   cp 60
   jr z,nodown
   inc a
   ld (y),a
nodown:   bit 3,b
   jr nz,noup
   ld a,(y)
   cp 10
   jr z,noup
   dec a
   ld (y),a
noup:   bit 1,b
   jr nz,noleft
   ld a,(x)
   cp 0
   jr z,noleft
   dec a
   ld (x),a
noleft:   bit 2,b
   jr nz,norght
   ld a,(x)
   cp 88
   jr z,norght
   inc a
   ld (x),a
norght: ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   ret

;-------------------------
;>>>>Enemy Bullet Code<<<<
;-------------------------
enemybullets:
   ld b,11
   call ionRandom
   sub 10
   ret m
   ld hl,ebuls
   ld b,10
feloop:   
   ld a,(hl)
   or a
   jr z,ebulletfound
   inc hl
   inc hl
   inc hl
   djnz feloop
   ret
ebulletfound:
   ld (hl),1
   inc hl
   push hl
   ld b,96
   call ionRandom
   pop hl
   ld (hl),a
   ld (exbul),a
   inc hl
   ld (hl),0
   call drawebullet
   ret
moveebullets:
   ld hl,ebuls
   ld b,10
emloop:   
   ld a,(hl)
   or a
   push hl
   push bc
   call nz,ebulletmove
   pop bc
   pop hl
   inc hl
   inc hl
   inc hl
   djnz emloop
   ret
ebulletmove:
   inc hl
   ld a,(hl)
   ld (exbul),a
   inc hl
   push hl
   call drawebullet
   pop hl
   ld a,(return)
   or a
   ret nz
   push hl
   call checkecollision
   pop hl   
   ld a,(hl)
   inc a
   cp 64
   jr nz,eok
   dec hl
   dec hl
   ld (hl),0
   ret
eok:
   ld (hl),a
   call drawebullet
   ret
[color=red]
checkecollision:
   ld b,(hl)
   ld a,(y)
   sub b
   ret p
   ld a,(y)
   add a,3
   sub b
   ret m
   ld a,(exbul)
   add a,1
   ld b,a
   ld a,(x)
   sub b
   ret p
   ld a,(x)
   add a,9
   sub b
   ret m
   dec hl
   dec hl
   ld (hl),0
   ld de,explosiondata
   ld b,5
ploop:
   ld a,(de)
   or a
   jr z,found1
   inc de
   inc de
   inc de
   djnz ploop
   ret
found1:
   ld a,1
   ld (de),a
   inc hl
   inc de
   ld a,(hl)
   ld (de),a
   inc hl
   inc de
   ld a,(hl)
   ld (de),a
   ret
[/color]
;----------------------
;>>Player Bullet Code<<
;----------------------
firebullets:
   ld a,group6
   out (1),a
   in a,(1)
   bit 5,a
   jr z,firebul
   ld a,0
   ld (bulpress),a
   ret
firebul:
   ld a,(bulpress)
   or a
   ret nz
   ld a,1
   ld (bulpress),a
   ld hl,bulletarray
   ld b,10
floop:   
   ld a,(hl)
   or a
   jr z,bulletfound
   inc hl
   inc hl
   inc hl
   djnz floop
   ret
bulletfound:
   ld a,1
   ld (hl),a
   inc hl
   ld a,(x)
   add a,3
   ld (hl),a
   ld (xbul),a
   inc hl
   ld a,(y)
   sub 5
   ld (hl),a
   push hl
   call drawbullet
   pop hl
   ret
movebullets:
   ld hl,bulletarray
   ld b,10
mloop:   
   ld a,(hl)
   or a
   push hl
   push bc
   call nz,bulletmove
   pop bc
   pop hl
   inc hl
   inc hl
   inc hl
   djnz mloop
   ret
bulletmove:
   inc hl
   ld a,(hl)
   ld (xbul),a
   inc hl
   push hl
   call drawbullet
   pop hl
   ld a,(return)
   or a
   ret nz
   ld a,(hl)
   dec a
   or a
   jp p,ok
   dec hl
   dec hl
   ld (hl),0
   ret
ok:
   ld (hl),a
   call drawbullet
   ret

erasebul:
   ld a,(hl)
   ld l,a
   ld a,(xbul)
   ld b,5
   ld ix,bullet
   call ionPutSprite
   ret
drawbullet:
   ld a,(hl)
   ld l,a
   ld a,(xbul)
   ld b,5
   ld ix,bullet
   call ionPutSprite
   ret
drawebullet:
   ld a,(hl)
   ld l,a
   ld a,(exbul)
   ld b,3
   ld ix,ebullet
   call ionPutSprite
   ret
nosave:               ;~
   ld a,0            ;
   ld (saveflag),a         ;No
   ld b,30            ;Save
   ld hl,bulletarray      ;Game
nosveloop:            ;exit
   ld a,0            ;code
   ld (hl),a         ;
   inc hl            ;
   djnz nosveloop         ;
   EI            ;
   ret            ;~
gameexit:            ;~
   ld b,30            ;
   ld hl,ebuls         ;
l2loop:               ;
   ld (hl),0         ;
   inc hl            ;
   djnz l2loop         ;
   ld a,group6         ;
   out (1),a         ;
   in a,(1)         ;
   bit 7,a            ;
   jr z,nosave         ;
   ld a,1            ;
   ld (saveflag),a         ;
   ld hl,savepcoord      ;
   ld a,(x)         ;Game
   ld (hl),a         ;Exit
   inc hl            ;code
   ld a,(y)         ;
   ld (hl),a         ;
   ld hl,savepbullets      ;
   ld de,bulletarray      ;
   ld b,30            ;
svloop:               ;
   ld a,(de)         ;
   ld (hl),a         ;
   inc hl            ;
   inc de            ;
   djnz svloop         ;
   EI            ;
   ret            ;~

;----------------------
;>>>>Load Game Code<<<<
;----------------------
loadgmecode:
   ld a,(saveflag)
   ld (return),a
   or a
   ret z
   ld hl,savepcoord
   ld a,(hl)
   ld (x),a
   inc hl
   ld a,(hl)
   ld (y),a
   ld hl,savepbullets
   ld de,bulletarray
   ld b,30
ldloop:
   ld a,(hl)
   ld (de),a
   inc de
   inc hl
   djnz ldloop
   ret

ship:
   .db %00011000
   .db %00111100
   .db %00111100
   .db %10111101
   .db %10111101
   .db %11111111
   .db %01111110
bullet:
   .db %11000000
   .db %11000000
   .db %11000000
   .db %11000000
   .db %11000000
ebullet:
   .db %01000000
   .db %11100000
   .db %01000000
[color=red]
explosionimage:
    .db %00000000
   .db %00000100
   .db %01100100
    .db %00011000
    .db %00110000
    .db %00101100
    .db %01000010
    .db %00000000
;explosion2
    .db %00000100
    .db %00010000
    .db %00101010
    .db %00100010
    .db %01000100
    .db %00101000
    .db %00000100
    .db %00110000
;explosion3
    .db %10100100
    .db %11001100
    .db %00101010
    .db %00010010
    .db %01000100
    .db %00110000
    .db %01001100
    .db %00000010
;explosion4
    .db %10000010
    .db %10101100
    .db %01001011
    .db %00101001
    .db %01000100
    .db %10010011
    .db %01010001
    .db %01001100
;explosion5      
    .db %10101011
    .db %00000100
    .db %11000110
    .db %00000001
    .db %01000101
    .db %10000000
    .db %00100010
    .db %01011001
[/color]

bulletarray:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

ebuls:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

explosiondata:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

putSpriteAnd:
    ld    e,l
    ld    h,$00
    ld    d,h
    add    hl,de
    add    hl,de
    add    hl,hl
    add    hl,hl               ;Find the Y displacement offset
    ld    e,a
    and    $07               ;Find the bit number
    ld    c,a
    srl    e
    srl    e
    srl    e
    add    hl,de             ;Find the X displacement offset
    ld    de,gbuf
    add    hl,de
putSpriteAndLoop1:
    ld    d,(ix)             ;loads image byte into D
    ld    e,$00
    ld    a,c
    or    a
    jr    z,putSpriteAndSkip1
putSpriteAndLoop2:
    srl    d                  ;rotate to give out smooth moving
    rr    e
    dec    a
    jr    nz,putSpriteAndLoop2
putSpriteAndSkip1:
    ld    a,(hl)
    and    d
    ld    (hl),a
    inc    hl
    ld    a,(hl)
    and    e
    ld    (hl),a              ;copy to buffer using AND logic
    ld    de,$0B
    add    hl,de
    inc    ix                   ;Set for next byte of image
    djnz    putSpriteAndLoop1
    ret


.end
END
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 20 Mar 2009 11:11:34 am    Post subject:

The problem I think is in your putandsprite. It's not a good idea to use and for a sprite. instead, i'd use xor sprites and for your last explosion sprite have it erase the result of the other sprites xor'd together. Also, I don't quite understand what's happening with handle explosiondata. If you want to offset to an image, simply multiply by 8. Lastly, I'm a little confused of why you're keeping track of the status, x, and y for the explosiondata 5 times. The explosion isn't moving (when i tested), so you only need 2 bytes, and then 1 byte for the explosion sprite offset, cutting out 12 bytes. This also allows you to put more sprites for the explosion.

ps. I don't know if this is pindur or not, but I couldn't trigger anything until i had left the boundaries, and then it seemed like everything was being checked normally (boundary detection, bullet collision).
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 24 Mar 2009 06:57:39 pm    Post subject:

Sure enough, it was putAndSprite...I changed it to XOR the images to the screen, and that works fine. Plus, I dont know what I was doing with offsetting by 9...I instead changed it to offset by 8, like you suggested. And the one last item regarding why I put the explosion 5 times: I made the list as follows:

Code:

.nolist
#include "ion.inc"
#include "keys.inc"
.list

x = saferam1+0
y = saferam1+2
xbul = saferam1+4
exbul = saferam1+6
bulpress = saferam1+8
return = saferam1+10
timer = saferam1+12
temp1 = saferam1+14
enemydirection = saferam1+16
loadflag = saferam1+18

saveflag = saferam2+150
savepcoord = saferam2+152
savepbullets = saferam2+155

#ifdef TI83P
      .org  progstart-2
      .db   $BB,$6D
#else
     .org  progstart
#endif
     ret
     jr    nc,start
      .db   "~By Justin Niles",0

start:
   DI
   bcall(_clrlcdfull)
   bcall(_cleargbuf)
   ld a,40
   ld (x),a
   ld a,30
   ld (y),a
   call loadgmecode
   call movebullets
   ld a,0
   ld (return),a
   ld a,0
   ld (bulpress),a
   ld a,0
   ld (timer),a
[color=red]
   ld a,1
   ld (enemydirection),a        ;set the ships to start moving right (1=moving right; -1=moving left)
   ld hl,level_enemy_data
   ld de,level1_enemies        ;"level1_enemies" is similar to the explosions list: it contains 54 elements broken into sections of 3. 54/3=18 enemies
                                                      ;First element in a list of 3 holds the enemy type
                                                      ;Second element holds the x-coord of the enemy
                                                      ;Third element hold the y-coord of the enemy
   ld b,54
loop4:                                              ;load "level1_enemies" into "level_enemy_data"
   ld a,(de)
   ld (hl),a
   inc de
   inc hl
   djnz loop4
   call dispenemy1                 ;display the enemies onto the screen (this code is found towards the bottom)
[/color]
   ld hl,explosiondata
   ld b,5
loop3:
   ld (hl),0
   inc hl
   djnz loop3
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   call ionFastCopy

mainloop:
   ld a,group1
   out (1),a
   in a,(1)
   bit 6,a
   jp z,gameexit
[color=red]
   call handleenemies
[/color]
   call move
   call firebullets
   call movebullets
   call enemybullets
   call moveebullets
   call handleexplosions
   call ionFastCopy
   ld hl,timer
   inc (hl)
   jr mainloop
[color=red]
;-----------------------
;>>>>Enemy Ship Code<<<<
;-----------------------
handleenemies:
   ld a,(timer)                ;
   sub 4                        ;only move enemies every 4 cycles
   ret nz                        ;
   ld hl,level_enemy_data
   ld b,18                         ;set to loop through all 18 enemies
enemyloop:
   ld a,(hl)
   or a
   push bc
   push hl
   call nz,putenemy             ;if (hl)/=0, goto putenemy
   pop hl
   pop bc
   inc hl                             ;
   inc hl                             ;Increment "level_enemy_data" to the next set of 3 elements
   inc hl                             ;
   djnz enemyloop
   ret
putenemy:
   push hl
   rla                                 ;
   rla                                 ;Find the enemy image offset by multiplying a by 8.
   rla                                 ;
   sub 8                              ;then subtracting 8
   push af                        ;preserve a
   ld d,0
   ld e,a
   ld ix,enemyimages
   add ix,de                      ;essientially adding a to ix
   inc hl
   ld d,(hl)                        ;load enemy x-coord into d
   inc hl
   ld a,(hl)
   ld l,a                            ;load enemy y-coord into l
   ld a,d                         ;ld a,d
   ld b,8
   call ionPutSprite             ;copy Sprite using XOR logic
   pop af                        ;restore a
   pop hl                            ;restore hl
   ld d,0
   ld e,a
   ld ix,enemyimages
   add ix,de                       ;get image offset again
   inc hl
   ld d,(hl)                         ;load x-coord into d
;
   push hl                        ;preserve hl
   ld hl,enemydirection
   ld a,d                             ;ld a,(x-coord of enemy)
   sub 2
   jr nz,leftok
   ld (hl),1                          ;basically, if (x-coord of enemy)=2, then set the enemies to move right
leftok:   ld a,d                           ;reload a,(x-coord of enemy)
   sub 85
   jr nz,rightok
   ld (hl),-1                         ;if (x-coord of enemy)=85, then set the enemies to move left
rightok:
   ld a,d                           ;reload a,(x-coord of enemy)
   add a,(hl)                     ;add either 1 or -1 to the x-coord, causing the enemy to move either left or right
   ld d,a                                ;ld d,(new x-coord)
   pop hl                           ;restore hl
;
   ld (hl),a                       ;ld (x-coord of enemy),a
   inc hl
   ld a,(hl)
   ld l,a                           ;ld l,(y-coord of enemy)
   ld a,d                                ;ld a,d (which contains the new x-coord)
   ld b,8
   call ionPutSprite           ;copy the sprite to the screen using XOR logic
   ret
[/color]   

;----------------------
;>>>>Explosion Code<<<<
;----------------------
handleexplosions:
   ld a,(timer)
   sub 4
   ret nz
   ld hl,timer
   ld (hl),0
   ld hl,explosiondata
   ld b,5
exfloop:
   ld a,(hl)
   or a
   push hl
   push bc
   call nz,doexplosion
   pop bc
   pop hl
   inc hl
   inc hl
   inc hl
   djnz exfloop
   ret
doexplosion:
   push af
   push hl
   rla
   rla
   rla
   sub 8
   ld d,0
   ld e,a
   ld ix,explosionimage
   add ix,de
   inc hl
   ld d,(hl)
   inc hl
   ld a,(hl)
   ld l,a
   ld a,d
   ld b,8
   call ionPutSprite
   pop hl
   pop af
   inc (hl)
   sub 9
   jr nz,skipover1
   ld (hl),0
skipover1:
   ld a,(hl)
   or a
   ret z
   rla
   rla
   rla
   sub 8
   ld d,0
   ld e,a
   ld ix,explosionimage
   add ix,de
   inc hl
   ld d,(hl)
   inc hl
   ld a,(hl)
   ld l,a
   ld a,d
   ld b,8
   call ionPutSprite
   ret
   
;-----------------------------
;>>Player Ship Movement Code<<
;-----------------------------
move:
   ld a,group0      ;
   out (1),a      ;
   in a,(1)      ;determine if arrow
   ld b,4         ;keys were pressed
movl:   rra         ;
   jr c,aropres      ;
   djnz movl      ;
   ret         ;else: return
aropres:
   ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   in a,(1)
   ld b,a
   bit 0,b
   jr nz,nodown
   ld a,(y)
   cp 60
   jr z,nodown
   inc a
   ld (y),a
nodown:   bit 3,b
   jr nz,noup
   ld a,(y)
   cp 10
   jr z,noup
   dec a
   ld (y),a
noup:   bit 1,b
   jr nz,noleft
   ld a,(x)
   cp 0
   jr z,noleft
   dec a
   ld (x),a
noleft:   bit 2,b
   jr nz,norght
   ld a,(x)
   cp 88
   jr z,norght
   inc a
   ld (x),a
norght: ld a,(y)
   ld l,a
   ld a,(x)
   ld b,7
   ld ix,ship
   call ionPutSprite
   ret

;-------------------------
;>>>>Enemy Bullet Code<<<<
;-------------------------
enemybullets:
   ld b,11
   call ionRandom
   sub 10
   ret m
   ld hl,ebuls
   ld b,10
feloop:   
   ld a,(hl)
   or a
   jr z,ebulletfound
   inc hl
   inc hl
   inc hl
   djnz feloop
   ret
ebulletfound:
   ld (hl),1
   inc hl
   push hl
   ld b,96
   call ionRandom
   pop hl
   ld (hl),a
   ld (exbul),a
   inc hl
   ld (hl),0
   call drawebullet
   ret
moveebullets:
   ld a,(timer)
   sub 2
   ret z
   sub 2
   ret z
   ld hl,ebuls
   ld b,10
emloop:   
   ld a,(hl)
   or a
   push hl
   push bc
   call nz,ebulletmove
   pop bc
   pop hl
   inc hl
   inc hl
   inc hl
   djnz emloop
   ret
ebulletmove:
   inc hl
   ld a,(hl)
   ld (exbul),a
   inc hl
   push hl
   call drawebullet
   pop hl
   ld a,(return)
   or a
   ret nz
   push hl
   jr checkecollision
return2:
   pop hl   
   ld a,(hl)
   inc a
   cp 64
   jr nz,eok
   dec hl
   dec hl
   ld (hl),0
   ret
eok:
   ld (hl),a
   call drawebullet
   ret
checkecollision:
   ld b,(hl)
   ld a,(y)
   sub b
   jp p,return2
   ld a,(y)
   add a,3
   sub b
   jp m,return2
   ld a,(exbul)
   add a,1
   ld b,a
   ld a,(x)
   sub 2
   sub b
   jp p,return2
   ld a,(x)
   add a,9
   sub b
   jp m,return2
   dec hl
   dec hl
   ld (hl),0
   ld de,explosiondata
   ld b,5
ploop:
   ld a,(de)
   or a
   jr z,found1
   inc de
   inc de
   inc de
   djnz ploop
   ret
found1:
   ld a,1
   ld (de),a
   inc hl
   inc de
   ld a,(hl)
   ld (de),a
   inc hl
   inc de
   ld a,(hl)
   ld (de),a
   ld a,(de)
   ld l,a
   dec de
   ld a,(de)
   ld b,8
   ld ix,explosionimage
   call ionPutSprite
   pop hl
   ret

;----------------------
;>>Player Bullet Code<<
;----------------------
firebullets:
   ld a,group6
   out (1),a
   in a,(1)
   bit 5,a
   jr z,firebul
   ld a,0
   ld (bulpress),a
   ret
firebul:
   ld a,(bulpress)
   or a
   ret nz
   ld a,1
   ld (bulpress),a
   ld hl,bulletarray
   ld b,10
floop:   
   ld a,(hl)
   or a
   jr z,bulletfound
   inc hl
   inc hl
   inc hl
   djnz floop
   ret
bulletfound:
   ld a,1
   ld (hl),a
   inc hl
   ld a,(x)
   add a,3
   ld (hl),a
   ld (xbul),a
   inc hl
   ld a,(y)
   sub 6
   ld (hl),a
   push hl
   call drawbullet
   pop hl
   ret
movebullets:
   ld hl,bulletarray
   ld b,10
mloop:   
   ld a,(hl)
   or a
   push hl
   push bc
   call nz,bulletmove
   pop bc
   pop hl
   inc hl
   inc hl
   inc hl
   djnz mloop
   ret
bulletmove:
   inc hl
   ld a,(hl)
   ld (xbul),a
   inc hl
   push hl
   call drawbullet
   pop hl
   ld a,(return)
   or a
   ret nz
   ld a,(hl)
   dec a
   or a
   jp p,ok
   dec hl
   dec hl
   ld (hl),0
   ret
ok:
   ld (hl),a
   call drawbullet
   ret

erasebul:
   ld a,(hl)
   ld l,a
   ld a,(xbul)
   ld b,5
   ld ix,bullet
   call ionPutSprite
   ret
drawbullet:
   ld a,(hl)
   ld l,a
   ld a,(xbul)
   ld b,5
   ld ix,bullet
   call ionPutSprite
   ret
drawebullet:
   ld a,(hl)
   ld l,a
   ld a,(exbul)
   ld b,3
   ld ix,ebullet
   call ionPutSprite
   ret
nosave:               ;~
   ld a,0            ;
   ld (saveflag),a         ;No
   ld b,30            ;Save
   ld hl,bulletarray      ;Game
nosveloop:            ;exit
   ld a,0            ;code
   ld (hl),a         ;
   inc hl            ;
   djnz nosveloop         ;
   EI            ;
   ret            ;~
gameexit:            ;~
   ld b,30            ;
   ld hl,ebuls         ;
l2loop:               ;
   ld (hl),0         ;
   inc hl            ;
   djnz l2loop         ;
   ld a,group6         ;
   out (1),a         ;
   in a,(1)         ;
   bit 7,a            ;
   jr z,nosave         ;
   ld a,1            ;
   ld (saveflag),a         ;
   ld hl,savepcoord      ;
   ld a,(x)         ;Game
   ld (hl),a         ;Exit
   inc hl            ;code
   ld a,(y)         ;
   ld (hl),a         ;
   ld hl,savepbullets      ;
   ld de,bulletarray      ;
   ld b,30            ;
svloop:               ;
   ld a,(de)         ;
   ld (hl),a         ;
   inc hl            ;
   inc de            ;
   djnz svloop         ;
   EI            ;
   ret            ;~

;----------------------
;>>>>Load Game Code<<<<
;----------------------
loadgmecode:
   ld a,(saveflag)
   ld (return),a
   or a
   ret z
   ld hl,savepcoord
   ld a,(hl)
   ld (x),a
   inc hl
   ld a,(hl)
   ld (y),a
   ld hl,savepbullets
   ld de,bulletarray
   ld b,30
ldloop:
   ld a,(hl)
   ld (de),a
   inc de
   inc hl
   djnz ldloop
   ret
[color=red]
dispenemy1:
   ld hl,level_enemy_data
   ld b,18
enemyloop1:
   ld a,(hl)
   or a
   push bc
   push hl
   call nz,putenemy
   pop hl
   pop bc
   inc hl
   inc hl
   inc hl
   djnz enemyloop1
   ret
putenemy1:
   rla
   rla
   rla
   sub 8
   ld d,0
   ld e,a
   ld ix,enemyimages
   add ix,de
   inc hl
   ld d,(hl)
   inc hl
   ld a,(hl)
   ld l,a
   ld a,d
   ld b,8
   call ionPutSprite
   ret
[/color]
ship:
   .db %00011000
   .db %00111100
   .db %00111100
   .db %10111101
   .db %10111101
   .db %11111111
   .db %01111110
bullet:
   .db %11000000
   .db %11000000
   .db %11000000
   .db %11000000
   .db %11000000
ebullet:
   .db %01000000
   .db %11100000
   .db %01000000

explosionimage:
       .db %00000000
       .db %00000000
      .db %00010000
       .db %00111000
      .db %00011100
      .db %00111000
      .db %00000000
      .db %00000000
;explosionimage2:
      .db %00000000
      .db %00001000
     .db %00101100
      .db %00011110
      .db %01100100
      .db %00010110
      .db %00011000
      .db %00000000
;explosionimage3:
       .db %00000010
       .db %00101100
       .db %01100101
       .db %01011111
       .db %00110000
       .db %00010110
       .db %01100010
       .db %00010000
;explosionimage4:
       .db %00001100
       .db %01010010
       .db %00100101
       .db %00010010
       .db %11101101
       .db %00010110
       .db %01010010
       .db %00110001
;explosionimage5:
       .db %01010001
       .db %11001101
       .db %01111010
       .db %00111111
       .db %01001010
       .db %10111100
       .db %00101010
       .db %01010101
;explosionimage6:
       .db %11100101
       .db %00010000
       .db %01011010
       .db %10000010
       .db %00000000
       .db %11010001
       .db %00101010
       .db %10101001
;explosionimage7:
       .db %10001001
       .db %00100010
      .db %00000000
       .db %01000010
       .db %00000000
       .db %10000001
       .db %00100010
       .db %10001001
;explosionimage8:
       .db %01000011
       .db %00000001
       .db %10000000
       .db %00000000
       .db %00000000
       .db %00000000
       .db %00000001
       .db %11000101
;explosionimage9:
   .db %00000100
   .db %10000000
    .db %00000000
    .db %00000000
    .db %00000000
    .db %00000000
    .db %00000001
    .db %01000000
[color=red]
enemyimages:
;enemy image 1
       .db %10000001
       .db %10000001
       .db %10000001
       .db %01111110
       .db %00111100
       .db %00011000
   .db %00000000
   .db %00000000
[/color]


bulletarray:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

ebuls:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

explosiondata:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
[color=red]
level_enemy_data:
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
   .db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

level1_enemies:
   .db 1,3,5,1,16,5,1,29,5,1,42,5,1,55,5,1,68,5
   .db 1,3,15,1,16,15,1,29,15,1,42,15,1,55,15,1,68,15
   .db 1,3,25,1,16,25,1,29,25,1,42,25,1,55,25,1,68,25
[/color]

.end
END
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 24 Mar 2009 09:32:16 pm    Post subject:

For some reason when I tried running your test code, it crashes at dispenemy1. I commented it out, and now it does the ghosting thing you were talking about. I think your error might be somewhere in dispenemy1. I'll examine it later when i have more time.
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 25 Mar 2009 12:11:12 am    Post subject:

In dispenemy1 I believe you are calling putenemy instead of putenemy1. Could that be the problem?

Last edited by Guest on 11 Jul 2010 05:58:11 pm; edited 1 time in total
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 25 Mar 2009 05:05:24 pm    Post subject:

calc84maniac, you were right. I was in fact calling putenemy, instead of putenemy1. Thanks so much for your help!

WikiGuru, I believe that there may be something wrong with PindurTI, because the call dispenemy1 works perfectly fine on my emulator. Also,the boundary problem you said you had, back a couple of posts, never occurred when I tried to run the program. Is there any particular reason you use PindurTI? If not, have you checked out Wabbitemu? It perfectly emulates the TI83,TI83+,TI83+SE, and the same for the TI84 family. I'm pretty sure it runs TI82s, also.
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 25 Mar 2009 05:53:44 pm    Post subject:

Yeah, i think you're right. It might just be a pindurti issue. The only reason I use pindur is because it's partially integrated with latenite (lame, i know, but i'm kind of lazy)
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 26 Mar 2009 08:39:55 am    Post subject:

Neither WabbitEmu or PTI 'perfectly' emulate any model of calc however they are very close. Using either is fine. If you believe you have narrowed down a bug, it would be wise to contact the author about it.
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 26 Mar 2009 12:49:50 pm    Post subject:

To be quite honest, I don't know what the bug is. I think latenite came with a rather old version of pindurti, so it might have been fixed and I just haven't replace the executable yet.
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 27 Mar 2009 12:20:54 pm    Post subject:

oh, ok. WikiGuru, do your other programs run fine on PTI?

tr1p1ea, when I said "perfectly emulates [those calculators]", it was a figure of speech. For what I've run and tested on the WabbitEmu, it emulates fairly close to perfect. Haha, I know that WabbitEmu will always have some flaw or something that is impossible to emulate on the computer, but for the purposes of beginning, intermediate, and even many advanced programmers, it runs flawlessly enough for them (and me). I do appreciate, however, your clarification! Sorry for any misconceptions!
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 27 Mar 2009 12:32:08 pm    Post subject:

most of them due, but there are a few every now and then that have funny issues (like this one)
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 27 Mar 2009 12:40:02 pm    Post subject:

Alright, that's not so bad. Ya, I tried downloading Pindur at one point. I downloaded it, but after reading the README file, I realized that the person who made the emulator wasn't making any improvements to it, and didn't have any plans to do so in the future. So after a bit more searching, I found WabbitEmu, which has active support and constant updates. Have you ever used Tilem, out of curiousity?
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 27 Mar 2009 02:24:32 pm    Post subject:

Yeah, but i stopped when i got my laptop. It was kind of a hassle to use, and kept crashing on me. I haven't done much calc programming lately, and usually when I do, pindurti suites my tests. I do have wabbitemu and use it for homework when i'm too lazy to pull out my real calc, or when i want to test something that works only on the 83+se/84+ series (basically anything but the 83+ regular).
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement