After a long programmatical "dark age" I decided to get back into assembly programming, because I kind of missed it. The first project I revitalized was my Yahtzee game for the TI-84+, this time done as a CE program.

To my surprise I quickly got a working compile that did not crash. However, graphical issues persisted, which I fixed with the help of a few individuals in SAX. Now, I find that the program crashes right as soon as I press Clear from the splash screen. Now I ran the program again, pressing a few other keys (to ensure the glitch wasn't happening in the in-game getCSC loop), and it doesn't crash. It crashes when i press Clear. This leads me to believe that the crashing code is within the below segment. The crash occurs whether I do the resetting this way or call gfx_End. I have enclosed the source of my program thus far below.

Code:

Quit:
   call _ClrScrn
    ld a,lcdbpp16
    ld (mpLcdCtrl),a
    call _DrawStatusBar
    ei
    ret


Source: http://pastebin.com/esGkBAZ2

* I changed the kdbscan loop to be very minimal, ensuring no other code is executing in the loop. You should literally press Clear, and then the game quits.

Edit: Because its missing from the paste, the content of the MainMenu label:


Code:

MainMenu:
; SPLASH SCREEN
; set screen to yellow
   ld a, cYellow \ ld hl, vram
   ld bc, 320*240
   call _MemSet
; create red banner
   ld a, cRed \ ld hl, vram
   ld bc, 320*45
   call _MemSet
; render text
   ld a, cYellow \ ld hl, 0
   ld l, a
   push hl
      call gfx_SetTextFGColor
   pop hl
   ld a, cRed \ ld l, a
   push hl
      call gfx_SetTextBGColor
   pop hl
   ld hl,3
   push hl
      push hl
         call gfx_setTextScale
      pop hl
   pop hl
   ld hl, 0 \ ld bc, 0 \ ld de, 0
   ld l, 10 \ ld c, 32 \ ld de, TitleText
   push hl
      push bc
         push de
            call gfx_PrintStringXY
         pop de
      pop bc
   pop hl
   ld a, cRed \ ld hl, 0
   ld l, a
   push hl
      call gfx_SetTextFGColor
   pop hl
   ld a, cYellow \ ld l, a
   push hl
      call gfx_SetTextBGColor
   pop hl
   ld hl,2
   push hl
      push hl
         call gfx_setTextScale
      pop hl
   pop hl
   ld hl, 0
   ld l, 70 \ ld c, 7 \ ld de, AnyKeyText
   push hl
      push bc
         push de
            call gfx_PrintStringXY
         pop de
      pop bc
   pop hl
   ld hl, 2
   push hl
      push hl
         ld hl, 150 \ ld bc, 60
         push hl
            push bc
               ld hl, Die1
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
            ld hl, 92
            push hl
               ld hl, Die2
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
            ld hl, 124
            push hl
               ld hl, Die3
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
            ld hl, 156
            push hl
               ld hl, Die4
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
            ld hl, 188
            push hl
               ld hl, Die5
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
            ld hl, 220
            push hl
               ld hl, Die6
               push hl
                  call gfx_SSprite
               pop hl
            pop hl
         pop hl
      pop hl
   pop hl
   ret

Crash: Resolved
New crash in the following code. I have my push/pops indented. Each sprite is 16x16 (plus 2 bytes for size), and being scaled up to 32. Trying to get 2 pixels of space in between each sprite.

http://pastebin.com/jvDfF9iM

Edit: what I see.

- I get the 5 empty die rendering as i should (placeholder) - die0.
- I get random mutlicolor glitching at the top of the screen.
- I get what appears to be random parts of the other sprites stepping across the screen, from the top right and heading diagonally down.
- Pressing the [2nd] key or the Graph keys instantly crashes.
- Pressing [Clear] to exit the game gave me a randomly super big home screen followed by a crash the first time. The second time, I got a TI Basic error syntax, then a crash.

** the game was stable until i added the above code

Crash Resolved

New Issue: Crash repeats AFTER a successful roll of the die (during which each call to my [Zeda's] random routine returns 0). Crash occurs at first call to gfx_SSprite after rolling. Relevant source materials linked here: http://pastebin.com/UFH8AYaa
While I couldn't find the bug, I have a couple of observations:
I didn't find any mismatched push/pop issues.
I didn't find any branching issues.

Your note that my rand routine was returning zeros made me notice that the seeding code might be an unrelated problem (it works, but not as well for the 24-bit version as it does for the 16-bit). Maybe try running prng24 ~10 times after seeding. If that doesn't fix the RNG problem, then I'm not sure where that bug is, either.
Current Alpha Release: https://www.mediafire.com/?d9hh0xybxbps48h
Build #66. Added - rolls limited to 3.
Known Bugs: posted below.

@Xeda: doing your unposted suggestion of calling prng24 at the start of the Key reading loop, gives me returns of like 90% 1 or 3 and a few scattered 5's. No other numbers.

Also, the following code works as a moderately effective GetKey with waiting for key release. However I do notice the following issues:

1. While most of the time, this routine will wait until i release the key, every so often, i'll still get multiple repeats of the action before the routine manages to lock up and wait. I'm assuming this is a timing issue?

2. When i press Clear, I'll get another roll, then have to press Clear a second time to exit the game.


Code:

KeyGetLoop:
   call prng24
   ld hl, $F50000 \ ld a, 1
    ld (hl), a      ; Set indiscriminate scan mode
Key_WaitLoop
   ld hl, $f50008
   bit 2, (hl) \ jr nz, Key_WaitLoop
   call _kbdscan
   ld a, (kbdScanCode)
   push af
   ld hl, $F50000 \ ld a, 1
    ld (hl), a      ; Set indiscriminate scan mode
Key_WaitRelease:
   ld hl, $f50008
   bit 2, (hl) \ jr z, Key_WaitRelease
   pop af
Game Progress Report:

Build #95
Current Alpha Binary: http://www.mediafire.com/file/q5b8x984iyacb2s/yahtzee.8xp
Known bugs: (1) sometimes pressing a key too long multi-bounces [add a double 'nop' right after setting mode 1 seems to help with this]; (2) Rolling the die produces only 1, 3, and 5.

Coming soon: auto-save, combo selection (going to the right of the score/high score interface)

Screenshot:
What does your dice-rolling routine look like?
KermMartian wrote:
What does your dice-rolling routine look like?


Code:
rand6:
;;Input: A is the range.
;;Output: Returns in A a random number from 0 to (input)A-1.
;;  B=0
;;  DE is a pseudo-random 16-bit integer.
;;Destroys:
;;  HL
;;Speed:
      call prng24
   xor a
   ld b,h
   ld c,l
   add hl,hl \ rla
   add hl,bc \ adc a,0
   add hl,bc \ rla
   inc a
    ret

prng24:
;collab with Runer112
;;Output:
;;    HL is a pseudo-random int
;;    A and BC are also, but much weaker and smaller cycles
;;    Preserves DE
;;148cc, super fast
;;26 bytes
;;period length: 4,294,901,760
seed1=$+1
    ld hl,9999
    ld b,h
    ld c,l
    add hl,hl
    add hl,hl
    inc l
    add hl,bc
    ld (seed1),hl
seed2=$+1
    ld hl,987
    add hl,hl
    sbc a,a
    and %00101101
    xor l
    ld l,a
    ld (seed2),hl
    add hl,bc
    ret


Also, updated screenshot:

I'm wondering if I should leave the Combo lists in this format, or do two horizontal bars like I did in the greyscale version? The latter would give me more wiggle room on screen. Thoughts?
  
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
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement