Author |
Message |
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
Posted: 13 Nov 2003 02:12:02 pm Post subject: |
|
|
Hello everyone,
I am new to assembly programming. I tried to make a prime search program, which worked quite well. But now im trying to make a game (remake astroidsbelt). I already wrote code for the astroids which scroll from the top to the bottum. It works but after a few seconds everything crashes. The flash debugger says invalid z80 instruction. I am desperate i looked thru the code about hundreds times but could not find what's wrong. I even rewrote the whole thing, but still the same error!
Do you know what the problem is? Thanks in forward!
Appelhorne
PS Sorry for my bad english
My code
#include ti83plus.inc
#include mirage.inc
;Defines
bAst1X = SafeRam1
bAst1Y = SafeRam1 + 1
bAst2X = SafeRam1 + 2
bAst2Y = SafeRam1 + 3
bAst3X = SafeRam1 + 4
bAst3Y = SafeRam1 + 5
bAst4X = SafeRam1 + 6
bAst4Y = SafeRam1 + 7
bAst5X = SafeRam1 + 8
bAst5Y = SafeRam1 + 9
.org 9D93h
.db $BB, $6D ;compiled asmprgm token
ret
.db 1 ;MirageOS token
;MirageOS Icon
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
.db %00000000, %00000000
;Discription
.db "The Asteroid Belt",0
;Program entry point
Initialize:
xor a
ld (bAst1X), a
ld (bAst1Y), a
ld a, 20
ld (bAst2X), a
ld (bAst2Y), a
ld a, 40
ld (bAst3X), a
ld (bAst3Y), a
ld a, 50
ld (bAst4X), a
ld (bAst4Y), a
ld a, 60
ld (bAst5X), a
ld (bAst5Y), a
;The main loop!
MainLoop:
;Blitting the astroids!
;Ast1
bcall(_grbufclr)
ld b, 8
ld a, (bAst1Y)
ld l, a
ld a, (bAst1X)
ld ix, sprRock
call isprite
;Ast2
ld b, 8
ld a, (bAst2Y)
ld l, a
ld a, (bAst2X)
ld ix, sprRock
call isprite
;Ast3
ld b, 8
ld a, (bAst3Y)
ld l, a
ld a, (bAst3X)
ld ix, sprRock
call isprite
;Ast4
ld b, 8
ld a, (bAst4Y)
ld l, a
ld a, (bAst4X)
ld ix, sprRock
call isprite
;Ast5
ld b, 8
ld a, (bAst5Y)
ld l, a
ld a, (bAst5X)
ld ix, sprRock
call isprite
;Flip!
call ifastcopy
;Check the astroids if they go beneath the screen
CheckAst1:
ld a, (bAst1Y)
cp 55
jp Z, ResetAstroid1
inc a
ld (bAst1Y), a
CheckAst2:
ld a, (bAst2Y)
cp 55
jp Z, ResetAstroid2
inc a
ld (bAst2Y), a
CheckAst3:
ld a, (bAst3Y)
cp 55
jp Z, ResetAstroid3
inc a
ld (bAst3Y), a
CheckAst4:
ld a, (bAst4Y)
cp 55
jp Z, ResetAstroid4
inc a
ld (bAst4Y), a
CheckAst5:
ld a, (bAst5Y)
cp 55
jp Z, ResetAstroid5
inc a
ld (bAst5Y), a
;Loop
jp MainLoop
;Routines for resetting the astroid
ResetAstroid1:
xor a
ld (bAst1Y), a
ld b, 87
call irandom
ld (bAst1X), a
jp CheckAst2
ResetAstroid2:
xor a
ld (bAst2Y), a
ld b, 87
call irandom
ld (bAst2X), a
jp CheckAst3
ResetAstroid3:
xor a
ld (bAst3Y), a
ld b, 87
call irandom
ld (bAst3X), a
jp CheckAst4
ResetAstroid4:
xor a
ld (bAst4Y), a
ld b, 87
call irandom
ld (bAst4X), a
jp CheckAst5
ResetAstroid5:
xor a
ld (bAst5Y), a
ld b, 87
call irandom
ld (bAst5X), a
jp MainLoop
sprRock:
.db %00011000
.db %00111100
.db %01111110
.db %11111111
.db %11111111
.db %01111110
.db %00111100
.db %00011000 |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 13 Nov 2003 07:59:34 pm Post subject: |
|
|
Well, I compiled and ran it.
I experienced the exact same problem. I don't want this group to make a bad impression on you, so I will keep working on it.
BTW, what instruction did the debugger say was invalid?
Last edited by Guest on 13 Nov 2003 07:59:50 pm; edited 1 time in total |
|
Back to top |
|
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
Posted: 14 Nov 2003 12:54:42 pm Post subject: |
|
|
Thanks Jacob
The invalid instruction was on 9E1A.
The compiled thing looks like this:
Code: 0075 9E01
0076 9E01 ;Ast2
0077 9E01 06 08 ld b, 8
0078 9E03 3A EF 86 ld a, (bAst2Y)
0079 9E06 6F ld l, a
0080 9E07 3A EE 86 ld a, (bAst2X)
0081 9E0A DD 21 CE 9E ld ix, sprRock
0082 9E0E CD 89 40 call isprite
0083 9E11
0084 9E11 ;Ast3
0085 9E11 06 08 ld b, 8
0086 9E13 3A F1 86 ld a, (bAst3Y)
0087 9E16 6F ld l, a
0088 9E17 3A F0 86 ld a, (bAst3X)
0089 9E1A DD 21 CE 9E ld ix, sprRock
0090 9E1E CD 89 40 call isprite
0091 9E21
0092 9E21 ;Ast4
while in the debugger its totally different when it crashes.
It seems that the code has changed! |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 15 Nov 2003 01:51:48 am Post subject: |
|
|
That is so wierd. I haven't got clue as to your problem. But if one of the smart guys would get in here, they'd be able to fix it without a problem. Just sorry you have to wait so long to get started on your program. |
|
Back to top |
|
|
sgm
Calc Guru
Joined: 04 Sep 2003 Posts: 1265
|
Posted: 15 Nov 2003 02:46:16 am Post subject: |
|
|
Have you tried the VTI debugger (needs base code 1.12 or lower)? The flash debugger is supposed to be for Flash Apps and can be buggy with ASAPs.
Have you tried on an actual calculator? It's not like you could lose anything.
Last edited by Guest on 15 Nov 2003 02:47:26 am; edited 1 time in total |
|
Back to top |
|
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
Posted: 15 Nov 2003 11:10:28 am Post subject: |
|
|
I get the same problem on real calulators. VTI doesn't work here for some reason |
|
Back to top |
|
|
Darth Android DragonOS Dev Team
Bandwidth Hog
Joined: 31 May 2003 Posts: 2104
|
Posted: 15 Nov 2003 11:18:38 am Post subject: |
|
|
nope. vti doesnt yet support apps, so you wouldnt be able to load Mirage :(
//whats with this??? |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 15 Nov 2003 12:41:39 pm Post subject: |
|
|
Code: Initialize:
xor a
ld (bAst1X), a; valid coordinate
ld (bAst1Y), a; valid coordinate
ld a, 20
ld (bAst2X), a; valid coordinate
ld (bAst2Y), a; valid coordinate
ld a, 40
ld (bAst3X), a; valid coordinate
ld (bAst3Y), a; valid coordinate
ld a, 50
ld (bAst4X), a; valid coordinate
ld (bAst4Y), a; valid coordinate
ld a, 60
ld (bAst5X), a; valid coordinate
ld (bAst5Y), a;INVALID COORDINATE
In that last line of your initialization code you made the mistake of loading 60 into Asteroid 5's Y coordinate. This means that after the first write of Asteroid 5's sprite to the graph buffer you have written into a memory area beyond the graph buffer. By destroying data beyond that point it causes that calc to becom unstable and crash. Another thing I must point out, is it will continue to write beyond that point because it is beyond the limit you set in the CheckAst5 label. Which means it will continue to write further into memory until the value of it's y coordinate loops around past 255 and start counting back up to 55.
Therefore you need to change the y coordinate of asteroid 5 to something less than 55 or it will continue to crash. |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 15 Nov 2003 12:48:34 pm Post subject: |
|
|
Another thing I'd like to make mention of is that the 8*8 asteroids can be written up to the 56th Y-Coordinate. So you have one more row before you have to reset your asteroids. Just another tidbit of information. |
|
Back to top |
|
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
Posted: 18 Nov 2003 11:41:01 am Post subject: |
|
|
Thanks for your reply Justin!! I just finished Astroidsbelt! |
|
Back to top |
|
|
Justin W. Shattered Silence
Advanced Member
Joined: 24 May 2003 Posts: 429
|
Posted: 18 Nov 2003 01:30:14 pm Post subject: |
|
|
You're most welcome . It is also good to hear that you completed your game. Congratulations! |
|
Back to top |
|
|
JacobdeHaan
Member
Joined: 10 Jul 2003 Posts: 165
|
Posted: 20 Nov 2003 08:47:19 pm Post subject: |
|
|
So, where can we download it? |
|
Back to top |
|
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
|
Back to top |
|
|
sgm
Calc Guru
Joined: 04 Sep 2003 Posts: 1265
|
Posted: 04 Dec 2003 04:04:06 pm Post subject: |
|
|
Yes, IonRandom returns a random number in A (probably), and the high byte of the player's score at any point will be small and relatively constant, so the decision to make an asteroid large or small is based entirely on the result of a random number minus a constant.
Actually, I see now that you are actually subtracting the high byte of the address of the player's score, which will be some number around $90. Since the this is roughly the average of the results of IonRandom(255), you'll get a 50-50 mix of small and large asteroids every time. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 04 Dec 2003 06:42:35 pm Post subject: |
|
|
Code: ld hl, wScore should be Code: ld hl,(wScore) or maybe even Code: ld h,(wScore) but not sure about that one |
|
Back to top |
|
|
Appelhorne
Newbie
Joined: 13 Nov 2003 Posts: 9
|
Posted: 05 Dec 2003 12:59:52 pm Post subject: |
|
|
Thanks for the help!
I haven't tried your second advice yet, but i think it should be
ld h, (wScore + 1) |
|
Back to top |
|
|
|