Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
For those interested, here is a tutorial on how to port programs created for the CSE to the CE relatively quickly. What I did for two games, Puzzle Frenzy and Portal, is basically keep the screen in 16bpp, (switching the BGR mode to RGB), and then just modify my sprite routines. That is just graphics though. So, for instance, here is the routine for 4bpp on the CSE (Thanks PatrickD for the assistance Smile )


Code:
DrawSprite4bpp:
   ld   h,0
   ld   a,$50      ; set minimum Y
   ld   c,$11
   out   ($10),a
   out   ($10),a
   out   (c),h
   out   (c),l
   ld   a,$20      ; set current Y
   out   ($10),a
   out   ($10),a
   out   (c),h
   out   (c),l
   
   ex   de,hl      ; E = Y coordinate of top (screen coords)
   ld   a,(hl)      ; A = height of sprite
   inc   hl
   ld   c,(hl)      ; C = width of sprite in bytes
   inc   hl
   
   ld   (SaveHeight),a
   
   ld   a,c
   add   a,a
   add   a,a
   add   a,c      ; A = width in bytes * 5      
   ld   (SaveWidth),a
   
   ex   de,hl
   push   bc
   ld   a,b
   ld   l,a
   ld   h,0
   add   hl,hl
   ld   a,$52
   ld   c,$11
   out   ($10),a
   out   ($10),a
   out   (c),h
   out   (c),l
   sub   $31
   out   ($10),a
   out   ($10),a
   out   (c),h
   out   (c),l
   pop   bc
   
   ld   a,b
   add   a,c
   ld   l,a
   
   ld   h,0
   add   hl,hl
   dec   hl
   ld   a,$53
   ld   c,$11
   out   ($10),a
   out   ($10),a
   out   (c),h
   out   (c),l
   
   ld   hl,ColorTable
   ld   a,$22
   out   ($10),a
   out   ($10),a   
   
   ld   a,(SaveHeight)
   ld   b,a
DrawLoop:
   push   bc
   ld   a,(SaveWidth)
   ld   b,a
DrawLine:
   ld   a,(de)
   rra
   rra
   rra
   and   $1E
   ld   l,a
   outi
   outi
   ld   a,(de)
   rla
   and   $1E
   ld   l,a
   outi
   outi
   inc   de
   djnz   DrawLine
   pop   bc
   djnz   DrawLoop
   ret


And then the modified CE version:

Code:
DrawSprite4bpp:
 push ix
 ld c,l
 ex de,hl
 ld de,SaveW4bpp+1 ; Width
 call setSpriteBoundary
 ld hl,ColorTable+1
drawLoopLineNext:
 push bc
  push de
SaveW4bpp:
   ld b,0
drawLoopLine:
   push bc
    ld a,(ix)
    rra
    rra
    rra
    and $1E
    ld l,a
    ldi
    ldi
    ld a,(ix)
    rla
    and $1E
    ld l,a
    ldi
    ldi
    inc ix
   pop bc
   djnz drawLoopLine
   ex de,hl  ; de = hl
  pop hl
  ld bc,320*2
  add hl,bc
  ex de,hl
 pop bc
 djnz drawLoopLineNext
 pop ix
 ret
;--------------------------------------------------------------
; setSpriteBoundary
; Outputs
; hl->ColorTable
; de->vRam
; ix->data
; b=Height
;--------------------------------------------------------------
setSpriteBoundary:
 ld a,(hl)  ; a = w, b = h
 push af
  inc hl
  ld a,(hl)
  ld (de),a  ; Width
  inc hl  ; hl->data
  push hl

  ld hl,0
  ld l,b 
  ld a,c
  add hl,hl  ; b*2
  add hl,hl  ; b*4
  push hl  ; Save X
   ld de,320*2
   inc a
   ld b,8
   ld hl,0
   
   add hl,hl
   rlca
   jr nc,$+3
   add hl,de
   djnz $-5
   ld de,vRam-(320*2)
   add hl,de
  pop de  ; de=X
  add hl,de  ; Add X
  ex de,hl  ; de->place to draw
  pop ix
 pop bc
 ret


And just like that, I can keep the same format for all of my data. The main thing is rewriting the graphics functions to account for the memory-mapped screen. In addition, there are a couple differences when saving and loading the now 24 bit registers, and fixing up bcalls from the CSE. Here's some helpful macros: Wink

Code:
#macro bcall(x)
 call x
#endmacro
#macro b_call(x)
 call x
#endmacro

Of course, you also have to be careful when saving these registers to RAM, or else you might wipe out an extra byte. You don't really have to worry about loading them though; unless you are adding an subtracing, in which case you just have to clear the upper bit. Here's a really naive way to save! Smile

Code:
#macro ldhl(xxxx)
 push af
  ld a,l
  ld (xxxx),a
  ld a,h
  ld (xxxx+1),a
 pop af
#endmacro

Seriously though, if you have any specific questions, I could totally help, as could PatrickD.
Thank you for posting this guide, Mateo! It gave me the momentum that I needed to port Tetric A to the TI-84 Plus CE, and now I feel more confident grasping what a z80->ez80 port entails. I remain sad that there's no suffix for ld that will do the equivalent of your ldhl() routine, but it's an admirable replacement.
Hello I'm new to this community but I am eager to start coding and making programs/games, but I don't know where to start! Is there a specific program you guys use..? I have the TI-84 Plus CE and I would like to start coding and porting games.
Andathral, welcome to Cemetech! Please Introduce Yourself if you get a chance. Do you have experience with TI-BASIC and/or [e]z80 ASM? For ez80 ASM, we use SPASM-ng or SourceCoder 3 (which wraps SPASM-ng and a calculator emulator in an online tool); for TI-BASIC, SourceCoder, TokenIDE, TI Connect CE, or just coding on your calculator are all options.
I actually sadly have NO experience whatsoever. The only coding I have done is for Minecraft Mods, but as you can probably guess this is very different.
Andathral wrote:
I actually sadly have NO experience whatsoever. The only coding I have done is for Minecraft Mods, but as you can probably guess this is very different.
Yes indeed. Your best bet is to start with TI-BASIC, then take it from there. In the interest of keeping this topic on-topic, let's discuss that in a specific topic you might create for your questions, if you have some.
  
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 GMT - 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