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 )
Code:
And then the modified CE version:
Code:
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:
Code:
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!
Code:
Seriously though, if you have any specific questions, I could totally help, as could PatrickD.
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:
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!
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.