Hi

I wrote this program a while ago for the TI-83, but couldn't debug it.

What it's supposed to do is show part of matrix F and allow you to move around, and when you went offscreen, it would load a different section of the matrix.

Here's a basic version of my concept just to show you.
www.geocities.com/klopenator/Matrix.zip

And here's the ASM version:

Code:

call _runIndicOff
 ld a,8                     ;Variable Initalization
 ld (player_x),a            ;
 ld a,4                     ;
 ld (player_y),a            ;
 xor a                      ;
 ld (matrix_x_offset),a     ;
 ld (matrix_y_offset),a     ;

 call _zerooop1
 ld hl,op1
 ld (hl),rmatobj
 inc hl
 ld (hl),tvarmat
 inc hl
 ld (hl),tmatf
 call _chkfindsym
 jp c,_errundefined

matrixcall:
 call _clrLCDFull           ;Clears the screen
 xor a
 ld (currmatrix_x),a
 ld (currmatrix_y),a

matrix:                     ;This whole routine draws the map (matrix f) on the screen
 call _zerooop1             ;This whole thing puts matrix [F]'s address into de
 ld hl,op1                  ;
 ld (hl),rmatobj            ;
 inc hl                     ;
 ld (hl),tvarmat            ;
 inc hl                     ;
 ld (hl),tmatf              ;
 call _chkfindsym           ;Matrix element-grabbing variables
 ld a,(matrix_y_offset)     ;
 ld b,a                     ;
 ld a,(currmatrix_y)        ;
 add a,b                    ;
 inc a                      ;
 ld c,a                     ;
 ld a,(matrix_x_offset)     ;
 ld b,a                     ;
 ld a,(currmatrix_x)        ;
 add a,b                    ;
 inc a                      ;
 ld b,a                     ;
 call _getmtoop1            ;Gets the matrix value and stores it to op1
 call _convop1              ;Puts op1 into de
 ld a,e                     ;Compares to see if there is a wall value (1) there
 cp 1                       ;
 jp z,charput               ;If so, it displays it

inc:
 ld a,(currmatrix_x)        ;Checks to see if we are at the end of the screen already
 cp 15                      ;
 jp z,incy                  ;If so, increases the Y value and sets X back to 1
 inc a                      ;Adds 1 to the x position
 ld (currmatrix_x),a        ;
 jp matrix                  ;Goes back to the matrix loop

incy:
 ld a,1                     ;Resets the X-Position back to 1
 ld (currmatrix_x),a        ;
 ld a,(currmatrix_y)        ;Checks to see if it isn't at the end of the screen
 cp 7                       ;
 jp z,movereset             ;If it is, it goes into the main movement loop
 inc a                      ;Otherwise, it increases the Y-Position
 ld (currmatrix_y),a        ;
 jp matrix                  ;Goes back to the matrix loop

charput:
 ld hl,(currmatrix_x)       ;Sets the x coordinate for display
 ld (CURCOL),hl             ;
 ld hl,(currmatrix_y)       ;Sets the y coordinate for display
 ld (CURROW),hl             ;
 ld hl,asterick             ;
 call _puts                 ;
 jp inc

movereset:
 jp display
move:                       ;The main moving loop
 ld a,KpadReset
 out (1),a
 ld a,Group1
 out (1),a
 in a,(1)
 cp KUp
 jp z,up
 cp KDown
 jp z,down
 cp KLeft
 jp z,left
 cp KRight
 jp z,right
 ld a,KpadReset
 out (1),a
 ld a,Group2
 out (1),a
 in a,(1)
 cp KClear
 jp z,return
 jp move

up:
 ld a,(player_y)
 cp 0
 jp z,mup
 call _zerooop1
 ld hl,op1
 ld (hl),rmatobj
 inc hl
 ld (hl),tvarmat
 inc hl
 ld (hl),tmatf
 call _chkfindsym
 ld a,(matrix_y_offset)
 ld b,a
 ld a,(player_y)
 add a,b
 ld c,a
 ld a,(matrix_x_offset)
 ld b,a
 ld a,(player_x)
 add a,b
 inc a
 ld b,a
 call _getmtoop1
 call _convop1
 ld a,e
 cp 0
 jp nz,move
 call clearplayer
 ld a,(player_y)
 inc a
 ld (player_y),a
 jp display

mup:
 ld a,(matrix_y_offset)
 cp 0
 jp z,move
 sub 8
 ld (matrix_y_offset),a
 ld a,(player_y)
 add a,7
 ld (player_y),a
 jp matrixcall

down:
 ld a,(player_y)
 cp 7
 jp z,mdown
 call _zerooop1
 ld hl,op1
 ld (hl),rmatobj
 inc hl
 ld (hl),tvarmat
 inc hl
 ld (hl),tmatf
 call _chkfindsym
 ld a,(matrix_y_offset)
 ld b,a
 ld a,(player_y)
 add a,b
 inc a
 inc a
 ld c,a
 ld a,(matrix_x_offset)
 ld b,a
 ld a,(player_x)
 add a,b
 inc a
 ld b,a
 call _getmtoop1
 call _convop1
 ld a,e
 cp 0
 jp nz,move
 call clearplayer
 ld a,(player_y)
 inc a
 ld (player_y),a
 jp display

mdown:
 ld a,(matrix_y_offset)
 cp 8
 jp z, move
 add a,8
 ld (matrix_y_offset),a
 ld a,(player_y)
 sub 7
 ld (player_y),a
 jp matrixcall

left:
 ld a,(player_x)
 cp 0
 jp z,mleft
 call _zerooop1
 ld hl,op1
 ld (hl),rmatobj
 inc hl
 ld (hl),tvarmat
 inc hl
 ld (hl),tmatf
 call _chkfindsym
 ld a,(matrix_y_offset)
 ld b,a
 ld a,(player_y)
 add a,b
 inc a
 ld c,a
 ld a,(matrix_x_offset)
 ld b,a
 ld a,(player_x)
 add a,b
 ld b,a
 call _getmtoop1
 call _convop1
 ld a,e
 cp 0
 jp nz,move
 call clearplayer
 ld a,(player_x)
 dec a
 ld (player_x),a
 jp display

mleft:
 ld a,(matrix_x_offset)
 cp 0
 jp z,move
 sub 16
 ld (matrix_x_offset),a
 ld a,(player_x)
 add a,15
 ld (player_x),a
 jp matrixcall

right:
 ld a,(player_x)
 cp 15
 jp z,mright
 call _zerooop1
 ld hl,op1
 ld (hl),rmatobj
 inc hl
 ld (hl),tvarmat
 inc hl
 ld (hl),tmatf
 call _chkfindsym
 ld a,(matrix_y_offset)
 ld b,a
 ld a,(player_y)
 add a,b
 inc a
 ld c,a
 ld a,(matrix_x_offset)
 ld b,a
 ld a,(player_x)
 add a,b
 inc a
 inc a
 ld b,a
 call _getmtoop1
 call _convop1
 ld a,e
 cp 0
 jp nz,move
 call clearplayer
 ld a,(player_x)
 inc a
 ld (player_x),a
 jp display

mright:
 ld a,(matrix_x_offset)
 cp 16
 jp z,move
 add a,16
 ld (matrix_x_offset),a
 ld a,(player_x)
 sub 15
 ld (player_x),a
 jp matrixcall

display:
 ld hl,(player_x)
 ld (CURCOL),hl
 ld hl,(player_y)
 ld (CURROW),hl
 ld hl,person
 call _puts
 jp move

clearplayer:
 ld hl,(player_x)
 ld (CURCOL),hl
 ld hl,(player_y)
 ld (CURROW),hl
 ld hl,blank
 call _puts
 ret

person:
 .db "0",0

blank:
 .db " ",0

asterick:
 .db "*",0

return:
 call _clrLCDFull
 call _homeup
 ret


Hopefully, the bugs can be worked out.
  
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