http://calcg.org/newlogo2.png Not Logged in.
Login | Register

General Discussion Board \ Calculator Programming \ Calculator crashes on execution

Click here to log in (you must be logged in to post comments).

AuthorComment
tomix1024
Probe
Posted: 14 Dec 2011
08:55 GMT
Total Posts: 3
hi all
i have a TI 84+ calculator and i made a little maze generator in z80 asm
the problem is, that the calculator crashes after the program is finished. if i generate only a small (12x12px) maze it works, but if it goes over the whole screen tios crashes. this doesn't happen if i don't swap the plotSScreen, where the maze is drawn, to the screen.

anybody any idea why?

btw:
there shouldn't be a stack overflow or sth. like that.
it uses ca. 5kb max. and the stack pointer is where it was before after execution.
haveacalc
Guardian
avatar
Posted: 15 Dec 2011
01:13 GMT
Total Posts: 1111
Is it possible you're accidentally drawing into plotSScreen+768 and beyond? Also, what routine are you using to put it on the screen? GrBufCpy?

---
-quoted directly from most movies that don't exist (and some that do).
tomix1024
Probe
Posted: 15 Dec 2011
07:58 GMT
Total Posts: 3
thanks for your answer!

the program doesn't draw beyond plotSScreen+300h
and i use grbufcpy for displaying the drawn image
haveacalc
Guardian
avatar
Posted: 15 Dec 2011
11:11 GMT
Total Posts: 1111
Without seeing some code, it is a mystery ¯\_(ッ)_/¯

---
-quoted directly from most movies that don't exist (and some that do).
tomix1024
Probe
Posted: 16 Dec 2011
05:25 GMT
Total Posts: 3
ok here's the code:

.NOLIST
#define EQU .equ
#define equ .equ
#define END .end
#include "ti83plus.inc"
.LIST

.org 9D93h
.db $BB,$6D

start:
B_CALL(_ClrLCDFull)
B_CALL(_RunIndicOff)
B_CALL(_GrBufClr)
call cls

ld b, 1
ld c, 1
call res_pt
call depth_frist

B_CALL(_GrBufCpy)
B_CALL(_GetKey)
ret

depth_frist:
ld hl, 0
push hl

depth_loop:

; is stack empty?
ld a, b
or a
ret Z
ld a, c
or a
ret Z

; check all sides...
push bc
ld hl, 0
ld a , 0
ld (func_count), a
ld (func_array+0), hl
ld (func_array+2), hl
ld (func_array+4), hl
ld (func_array+6), hl

; right
ld a, 2
add a, b
cp 95
jp NC, skip_right
ld b, a
call get_pt
or a
jp Z, skip_right
;save function ptr
ld hl, func_array
ld a, (func_count)
ld d, 0
ld e, a
sla e
add hl, de
ld de, do_right
ld (hl), e
inc hl
ld (hl), d
inc a
ld (func_count), a
skip_right:

pop bc
push bc

; left
ld a, $fe
add a, b
cp 95
jp NC, skip_left
ld b, a
call get_pt
or a
jp Z, skip_left
;save function ptr
ld hl, func_array
ld a, (func_count)
ld d, 0
ld e, a
sla e
add hl, de
ld de, do_left
ld (hl), e
inc hl
ld (hl), d
inc a
ld (func_count), a
skip_left:

pop bc
push bc

; up
ld a, $fe
add a, c
cp 63
jp NC, skip_up
ld c, a
call get_pt
or a
jp Z, skip_up
;save function ptr
ld hl, func_array
ld a, (func_count)
ld d, 0
ld e, a
sla e
add hl, de
ld de, do_up
ld (hl), e
inc hl
ld (hl), d
inc a
ld (func_count), a
skip_up:

pop bc
push bc

; down
ld a, 2
add a, c
cp 63
jp NC, skip_down
ld c, a
call get_pt
or a
jp Z, skip_down
;save function ptr
ld hl, func_array
ld a, (func_count)
ld d, 0
ld e, a
sla e
add hl, de
ld de, do_down
ld (hl), e
inc hl
ld (hl), d
inc a
ld (func_count), a
skip_down:

pop bc

ld a, (func_count)
or a
jp NZ, success

; retry with prev
pop bc
jp depth_loop

; there's min. 1 working
success:
push bc

rnd_loop:
call random
and 3
ld hl, func_array
ld d, 0
ld e, a
sla e
add hl, de
ld a, (hl)
or a
jr NZ, end_rnd
jp rnd_loop
end_rnd:

ld e, (hl)
inc hl
ld d, (hl)
ex de, hl

jp (hl)

func_count:
.db $00
func_array:
.db $00,$00
.db $00,$00
.db $00,$00
.db $00,$00


do_left:
ld a, $ff
add a, b
ld b, a
call res_pt
ld a, $ff
add a, b
ld b, a
call res_pt
jp depth_loop
do_right:
ld a, 1
add a, b
ld b, a
call res_pt
ld a, 1
add a, b
ld b, a
call res_pt
jp depth_loop

do_up:
ld a, $ff
add a, c
ld c, a
call res_pt
ld a, $ff
add a, c
ld c, a
call res_pt
jp depth_loop
do_down:
ld a, 1
add a, c
ld c, a
call res_pt
ld a, 1
add a, c
ld c, a
call res_pt
jp depth_loop



; a, hl
cls:
ld hl, plotSScreen
ld a, 6
outer:
cp 0
ret Z
dec a
push af
ld a, 128
inner:
cp 0
jr Z, inner_end
dec a
ld (hl), $ff
inc hl
jr inner
inner_end:
pop af
jr outer


; b=x c=y
; a, de, hl
set_pt:
call join_coords
call split_coord
or (hl)
ld (hl), a
ret

; b=x c=y
; a, de, hl
res_pt:
call join_coords
call split_coord
xor $ff
and (hl)
ld (hl), a
ret

; b=x c=y
; a, de, hl
; a=bool
get_pt:
call join_coords
call split_coord
and (hl)
ret Z
ld a, 1
ret

; a = hl&7
; hl = hl<<3 + plotSScreen
; a, de, hl
split_coord:
ld a, l
and 7
ld d, 128
shift_loop:
cp 0
jr Z, shift_end
dec a
srl d
jr shift_loop
shift_end:

call shr_16
call shr_16
call shr_16

ld a, d

ld de, plotSScreen
add hl, de
ret

; hl = b + 96 * c
; a, de, hl
join_coords:
ld d, 0
ld e, c
ld h, 0
ld l, c
call shl_16
add hl, de

call shl_16
call shl_16
call shl_16
call shl_16
call shl_16

ld d, 0
ld e, b
add hl, de
ret

; hl >>= hl
; a, hl
shr_16:
srl l
ld a, h
srl h
and 1
ret Z
set 7, l
ret

; hl <<= hl
; a, hl
shl_16:
sla h
sla l
ret NC
inc h
ret

random:
ld a, (seed)
and $B8
scf
jp PO,no_clr
ccf
no_clr:
ld a, (seed)
rla
ld (seed), a
ret
seed:
.db $01

.end





Portal | My Account | Register | Lost Password or Username | TOS | Disclaimer | Help | Site Search | File Archives Copyright © 2002-2019 CalcG.org